Commit Graph

1981 Commits

Author SHA1 Message Date
Ingo Weinhold 13638944db Removed never read VMCache::scan_skip.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37195 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-21 15:10:37 +00:00
Ingo Weinhold 0d5ab7a14d Moved duplicate code from the VMTranslationMap subclasses' UnmapPage() and
ClearAccessedAndModified() implementations into helper methods PageUnmapped()
and UnaccessedPageUnmapped() in the base class.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37187 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-21 13:32:33 +00:00
Ingo Weinhold c955359cb6 Added vm_available_not_needed_memory_debug(), a
vm_available_not_needed_memory() version that can be called from within the
kernel debugger.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37167 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-18 20:57:05 +00:00
Ingo Weinhold f8e263c184 Slipped by in r37138: Added VMCache::Dump() and removed GetLock().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37141 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-15 00:07:18 +00:00
Ingo Weinhold 377ecfe797 * Renamed cache_type_to_string() to vm_cache_type_to_string() and made in
kernel private.
* Moved dumping code from dump_cache() to new VMCache::Dump().
* Override VMCache::Dump() in VMVnodeCache to also print the vnode.
* Removed no longer needed VMCache::GetLock().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37138 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-14 23:57:00 +00:00
Ingo Weinhold 0f48aa877a The ConstIterator only needs a const tree.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37137 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-14 23:51:54 +00:00
Ingo Weinhold a8ad734f1c * Introduced structures {virtual,physical}_address_restrictions, which specify
restrictions for virtual/physical addresses.
* vm_page_allocate_page_run():
  - Fixed conversion of base/limit to array indexes. sPhysicalPageOffset was not
    taken into account.
  - Takes a physical_address_restrictions instead of base/limit and also
    supports alignment and boundary restrictions, now.
* map_backing_store(), VM[User,Kernel]AddressSpace::InsertArea()/
  ReserveAddressRange() take a virtual_address_restrictions parameter, now. They
  also support an alignment independent from the range size.
* create_area_etc(), vm_create_anonymous_area(): Take
  {virtual,physical}_address_restrictions parameters, now.
* Removed no longer needed B_PHYSICAL_BASE_ADDRESS.
* DMAResources:
  - Fixed potential overflows of uint32 when initializing from device node
    attributes.
  - Fixed bounce buffer creation TODOs: By using create_area_etc() with the
    new restrictions parameters we can directly support physical high address,
    boundary, and alignment.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37131 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-14 16:25:14 +00:00
Ingo Weinhold 84e9db7fb7 x86 mmu_init(): Sum up the physical memory we ignore for whatever reason --
stored in kernel_args::ignored_physical_memory.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37116 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-12 15:57:21 +00:00
Travis Geiselbrecht 9623c48284 SMP: remove the tracking of apic id -> cpu id. Don't pass between bootloader and kernel.
Kernel doesn't use it, and it could be regenerated in the kernel if it did need it.

This also unlocks the apic range the bios can use. Previously the apic ids would have
to fit within 0..MAX_CPUS or it'd reject the cpu. Some boxes (mine in particular)
seem to sparsely populate the apic id so that the range is pretty large.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37108 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-12 01:01:54 +00:00
Ingo Weinhold f498c07968 Added STATIC_ASSERT() macro (from <Debug.h>, which cannot be included in the
kernel).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37087 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-10 17:31:57 +00:00
Ingo Weinhold 1d26c7248f vm_page_allocate_page_run(): Added parameter "limit", specifying the upper
physical address limit for the page run to allocate.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37086 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-10 17:30:49 +00:00
Ingo Weinhold 9e101ddfcc Definition for CR4 PAE bit.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37073 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-09 21:21:48 +00:00
Ingo Weinhold 641b3c82df Renamed allocate_early_physical_page() to vm_allocate_early_physical_page()
and made it public.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37072 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-09 21:21:18 +00:00
Ingo Weinhold 2ea7b17cf3 * vm_allocate_early(): Replace "bool blockAlign" parameter by a more flexible
"addr_t aligmnent".
* X86PagingMethod32Bit::PhysicalPageSlotPool::InitInitial(),
  generic_vm_physical_page_mapper_init(): Use vm_allocate_early()'s alignment
  feature instead of aligning by hand.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37070 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-09 11:15:43 +00:00
Ingo Weinhold 5aa0503c7c * Removed i386_translation_map_get_pgdir() and adjusted the one place where it
was used.
* Renamed X86VMTranslationMap to X86VMTranslationMap32Bit and pulled the paging
  method agnostic part into new base class X86VMTranslationMap.
* Moved X86PagingStructures into its own header/source pair.
* Moved pgdir_virt from X86PagingStructures to X86PagingStructures32Bit where
  it is actually used.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37055 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-08 00:20:34 +00:00
Ingo Weinhold 1ba89e67ed Removed no-op VMTranslationMap::InitPostSem() and
VMAddressSpace::InitPostSem().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37025 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-05 22:20:34 +00:00
Ingo Weinhold c3e021e862 x86:
* Renamed i386_context_switch() to x86_context_switch().
* x86_context_switch() no longer sets the page directory.
  arch_thread_context_switch() does that explicitly, now. This allows to solve
  the TODO by reordering releasing the previous paging structures reference and
  setting the new page directory.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37024 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-05 22:09:24 +00:00
Ingo Weinhold fabdf00e6a Renamed i386_swap_pgdir() to x86_swap_pgdir.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37023 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-05 21:53:32 +00:00
Ingo Weinhold 8421714089 x86:
* Renamed vm_translation_map_arch_info to X86PagingStructures, and all
  members and local variables of that type accordingly.
* arch_thread_context_switch(): Added TODO: The still active paging structures
  can indeed be deleted before we stop using them.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37022 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-05 21:51:05 +00:00
Ingo Weinhold 78dde7abd7 Consequently use uint32 for the physical page directory address.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37011 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-04 22:23:22 +00:00
Ingo Weinhold 8c9b84a588 Replaced the swap_addr_t and SWAP_SLOT_NONE in RadixBitmap.{h,cpp} by
radix_slot_t and RADIX_SLOT_NONE.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36998 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-02 20:42:53 +00:00
Ingo Weinhold 435c43f591 * Introduced type generic_io_vec, which is similar to iovec, but uses types
that are wide enough for both virtual and physical addresses.
* DMABuffer, IORequest, IOScheduler,... and code using them: Use
  generic_io_vec and generic_{addr,size}_t where necessary.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36997 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-02 18:42:20 +00:00
Ingo Weinhold e5846dfa61 Added shared sort_[physical_]address_ranges() to avoid code duplication. Also
fixes the m68k build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36951 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-27 17:08:47 +00:00
Ingo Weinhold d73ddac5bf * Introduced phys_addr_range type, an equivalent to addr_range for physical
address ranges, and a set of support functions working with it.
* Changed the type of the kernel_args physical address range arrays to
  phys_addr_range and adjusted the code working with those.
* Removed a bunch of duplicated address range code in the PPC's mmu.cpp.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36947 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-27 11:50:40 +00:00
Ingo Weinhold 147133b76c * First run through the kernel's private parts to use phys_{addr,size}_t
where appropriate.
* Typedef'ed page_num_t to phys_addr_t and used it in more places in
  vm_page.{h,cpp}.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36937 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-25 21:34:08 +00:00
Ingo Weinhold 9d570af7c8 Changed the type of the "op" parameter of the fs_vnode_ops::ioctl() hook and
the _kern_ioctl() syscall from ulong to uint32.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36927 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-24 21:04:22 +00:00
Ingo Weinhold f51bcfb25b Added a heap_init_post_area() which is called right after areas can be
created, and moved the heap's grow and VIP heap initialization to it. Should
fix #5956.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36855 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-18 15:51:27 +00:00
Ingo Weinhold 13fa4c845a * Introduced new area creation flag CREATE_AREA_DONT_COMMIT_MEMORY.
map_backing_store() doesn't commit memory when this flag is given.
* Used the new flag vm_copy_area(): We no longer commit memory for read-only
  areas. This prevents read-only mapped files from suddenly requiring memory
  after fork(). Might improve the situation on machines with very little RAM
  a bit.
  We should probably mark writable copies over-committing, since the usual
  case is fork() + exec() where the child normally doesn't need more than a
  few pages until calling exec(). That would significantly reduce the memory
  requirement for jamming the Haiku tree.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36651 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-06 14:59:14 +00:00
Ingo Weinhold 863c623f9a Added is_address_range_covered(), returning whether the given address range
is fully covered by the ranges in the array.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36631 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-05 21:09:11 +00:00
Axel Dörfler 8c8fcd770a * Moved the addition of the basic debugger commands directly after the VM init.
* Separated the other stuff previously done in debug_init_post_vm() to the new
  debug_init_post_settings().
* Removed superfluous status_t return codes - they are ignored, anyway, and if
  there really is a show stopper in the init process, panicking would be the
  thing one should do.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36623 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-05 10:05:25 +00:00
Ingo Weinhold c1be1e0761 * VMTranslationMap::Map()/Protect(): Added "memoryType" parameter. Not
implemented for any architecture yet.
* vm_set_area_memory_type(): Call VMTranslationMap::ProtectArea() to change the
  memory type for the already mapped pages.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36574 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-01 21:33:12 +00:00
Ingo Weinhold 3b0c1b5227 * VMArea: Made memory_type private and added setter and getter methods.
* Don't set the VMArea's memory type in arch_vm_set_memory_type(), but let the
  callers do that.
* vm_set_area_memory_type(): Does nothing, if the memory type doesn't change.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36573 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-01 20:41:57 +00:00
Ingo Weinhold 907886143f * Changed some parameters of VM syscalls from int to uint32, mostly for sake
of consistency.
* Moved the B_OVERCOMMITTING_AREA flag from B_KERNEL_AREA_FLAGS to
  B_USER_AREA_FLAGS, since we really allow it to be passed from userland.
* Most VM syscalls check the provided protection against B_USER_AREA_FLAGS
  instead of B_USER_PROTECTION, now. This way they allow for
  B_OVERCOMMITTING_AREA as well.
* _user_map_file(), _user_set_memory_protection(): Check the protection like
  the other syscalls do and use fix_protection() instead of doing that
  manually.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36572 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-01 19:47:39 +00:00
Ingo Weinhold 7f987e49d7 Added a rendez-vous variable parameter to smp_trap_non_boot_cpus() and make
boot CPU wait until all other CPUs are ready to wait. This solves a
theoretical problem in main(): The boot CPU could run fully through the early
initialization and reset sCpuRendezvous2 before the other CPUs left
smp_cpu_rendezvous(). It's very unlikely on real hardware that the non-boot
CPUs are so much slower, but it might be a concern in emulation.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36558 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-30 19:32:12 +00:00
Ingo Weinhold 28d05e026f Make scheduler_reschedule() an no-op until we're ready to start the
scheduler. This avoids the need to use the send_signal_etc() work-around for
resume_thread() during the early kernel initialization. Might fix #5851.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36530 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-29 15:10:37 +00:00
Ingo Weinhold b1e06d23ce * The "page_stats" command does now also print the longest contiguous runs of
free respective free and cached pages.
* Removed the unused vm_page_allocate_page_run_no_base().
* vm_page_allocate_page_run() (and allocate_page_run()):
  - Use vm_page_reserve_pages() instead of vm_page_try_reserve_pages(), i.e.
    wait until the reservation succeeds.
  - Now we iterates two times through the pages to find a suitable page run. In
    the first iteration it only looks for free/clear pages, in the second
    iteration it also considers cached pages. This increases the chance of the
    function to succeed, when a lot of caching is going on.
    This reduces the amount of memory required to use the IOCache when booting
    off the anyboot Live CD to around 160 MB in qemu. It also seems to work with
    128 MB, but the syslog indicates that some memory allocations fail, which
    is not exactly inspiring confidence.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36489 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-26 13:56:09 +00:00
Ingo Weinhold efeca209a1 Made VMCache::Resize() virtual and let VMAnonymousCache override it to free
swap space when the cache shrinks. Currently the implementation stil leaks
swap space of busy pages.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36373 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-20 14:04:18 +00:00
Axel Dörfler 868aa7a0e0 * Added shortcut handling to the boot loader menu (in preparation of adopting
ticket #5312).
* Added shortcut 'b' to continue booting, 'r' to reboot.
* Consolidated asterisk style.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36310 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-15 18:07:40 +00:00
Axel Dörfler 7af231d838 * Cleanup, no functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36305 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-15 17:05:20 +00:00
Axel Dörfler 9de17be600 * Moved I/O APIC initialization to a later point, now the APCI and DPC modules
can safely be used.
* Since using the I/O APIC is disabled by default, I've removed the "return"
  that prevented its use when enabled. Let's see if it already does anything.
* Adapted other arch_int.cpp with a bit of cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36290 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-15 12:42:10 +00:00
Ingo Weinhold c3676b54bf * Added vm_debug_copy_page_memory() which copies memory from a potentially not
mapped page.
* debug_{mem,strl}cpy():
  - Added "team" parameter for specifying the address space the address are
    to be interpreted in.
  - When the standard memcpy() (with fault handler) fails, fall back to
    vm_debug_copy_page_memory().
* Added debug_is_debugged_team(): Predicate returning true, if the supplied
  team_id refers to the same team debug_get_debugged_thread() belongs to.
* Added DebuggedThreadSetter class for scope-based debug_set_debugged_thread().
  Made use of it in several debugger functions.
* print_demangled_call() (x86): Fixed unsafe memory access.

Allows KDL stack traces to work correctly again, even if the page daemon has
already unmapped the concerned pages.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36230 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-13 17:40:15 +00:00
Ingo Weinhold 86875ad9d1 Added VMCache::DebugHasPage() and DebugLookupPage() for use in the kernel
debugger.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36228 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-13 17:18:57 +00:00
Ingo Weinhold 09418c869b Added DebugGet() method for use in the kernel debugger.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36227 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-13 17:16:42 +00:00
Michael Lotz 33fbe25496 * Add code to allocate and free interrupt vectors for message signaled
interrupts (MSI).
* Add the remaining IDT entries and redirection functions in the interrupt code.
* Make the PIC end_of_interrupt() return a result to indicate whether the vector
  was handled by this PIC. If it isn't we now issue a apic_end_of_interrupt()
  in the assumption of apic local interrupt, MSI or IPI. This also removes
  the need for the gUsingIOAPIC global and doing manual apic_end_of_interrupt()
  calls in the SMP and timer code.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36221 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-13 14:46:09 +00:00
Michael Lotz 3d310bd5f4 * Fix build, the APIC definitions are used in the bootloader too.
* Automatic whitespace cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36189 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-12 15:59:40 +00:00
Michael Lotz 5819c3f9ff Forgot to remove these in the previous commit.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36183 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-12 13:07:21 +00:00
Michael Lotz 655f3b4161 Seperate the generic (local) APIC stuff into it's own file and use it from the
other places where previously the same functionality was duplicated. Also
seperated the header which was originally arch_smp.h into apic.h and arch_smp.h
again as some of it is MP and not actually APIC.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36182 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-12 12:56:13 +00:00
Axel Dörfler ee0d2be9e4 bonefish+axeld:
* Implemented a tiny bit more sophisticated version of
  estimate_max_scheduling_latency() that uses a syscall that lets the scheduler
  decide.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36170 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-11 20:40:58 +00:00
Ingo Weinhold 813d4cbe94 * Moved created subdirectory src/system/kernel/lock.cpp to new subdirectory
locks.
* Added syscalls for a new kind of mutex. A mutex consists only of an int32 and
  doesn't require any kernel resources. So it's initialization cannot fail
  (it consists only of setting the mutex value to 0). An uncontended lock or
  unlock operation can basically consist of an atomic_*() in userland. The
  syscalls (when the mutex is contended) are a bit more expensive than semaphore
  operations, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36158 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-11 16:07:39 +00:00
Ingo Weinhold 349039ff2e Added vm_[un]wire_page(), which are essentially versions of
[un]lock_memory_etc() optimized for a single page.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36156 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-11 15:07:06 +00:00
Axel Dörfler 7f0bff63d0 * Fixed typo.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36058 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-07 07:05:20 +00:00
Ingo Weinhold 2be99447d8 * Added some comments to the thread flags.
* Added new thread flag THREAD_FLAGS_ALWAYS_RESTART_SYSCALL. If set, it forces
  syscall restart even when a signal handler without SA_RESTART was invoked.
* Fixed sigwait(): If one of requested signals wasn't already pending it would
  never wake up. Also, the syscall always needs to be restarted, if interrupted
  by another signal.
* Renamed a bunch of the POSIX signal function implementations which did return
  an error code directly (instead via errno). Added correct POSIX functions
  where needed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36054 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-06 20:23:18 +00:00
Ingo Weinhold 4f774c503c * VMArea::Unwire(addr_t, size_t, bool): Don't delete the removed range, but
return it.
* lock_memory_etc(): On error the VMAreaWiredRange object could be leaked.
* [un]lock_memory_etc(): Call VMArea::Unwire() with the cache locked and
  explicitly delete the range object after unlocking the cache to avoid
  potential deadlocks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36035 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-05 12:12:36 +00:00
Ingo Weinhold 369111e741 * Removed the VMArea::Wire() version that has to allocate a VMAreaWiredRange.
Since the requirement is that the area's top cache is locked, allocating
  memory isn't allowed.
* lock_memory_etc(): Create the VMAreaWiredRange object explicitly before
  locking the area's top cache.

Fixes #5680 (deadlocks when using the slab as malloc() backend).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36033 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-05 11:08:01 +00:00
Ingo Weinhold 550376ffb8 * vm_delete_areas(): Changed return type to void (was status_t and not used).
* _user_map_file(), _user_unmap_memory(): Verify that the address (if given) is
  page aligned.
* Reworked memory locking (wiring):
  - VMArea does now have a list of wired memory ranges and supports waiting for
    a range to be removed.
  - vm_soft_fault():
    - Added "wirePage" parameter that, if given, makes the function wire the
      page and return it.
    - Added "wiredRange" parameter (for calls from lock_memory_etc()) and made
      sure we never unmap wired pages. This could e.g. happen when a page from a
      lower cache was read-mapped and a write fault occurred. Now in such a
      situation the function waits for the page to be unwired and restarts.
  - All functions that manipulate areas in a way that could affect wired ranges
    do now either require the caller to make sure there are no wired ranges in
    the way or do that themselves. Added a few wait_if_*_is_wired() helper
    functions for that purpose.
  - lock_memory_etc():
    - Does now also work correctly when the range spans more than one area.
    - Adds VMAreaWiredRanges to the affected VMAreas and retains an address
      space reference (so that the address space won't be deleted as long as a
      wired range exists).
    - Resolved TODO: The area's caches are now locked when
      increment_page_wired_count() is called.
    - Resolved TODO: The race condition due to missing locking after looking up
      the page mapping is now prevented. We hold the cache locks (in case the
      page is already mapped) and the new vm_soft_fault() parameter allows us
      to get the page wired.
  - unlock_memory_etc(): Changes symmetrical to those in lock_memory_etc() and
    resolved all TODOs.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36030 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-03 18:01:29 +00:00
Ingo Weinhold feddedab0c x86:
Added fields for temporary storage of the debug registers dr6 and dr7 to the
arch_cpu_info structure. The actual registers are stored at the beginning of
x86_exit_user_debug_at_kernel_entry() and read in
x86_handle_debug_exception().
The problem was that x86_exit_user_debug_at_kernel_entry() itself overwrote
dr7 and, if kernel breakpoints were enabled, dr6 could be overwritten anytime
after. So x86_handle_debug_exception() would find incorrect values in the
registers (definitely in dr7) and thus interpret the detected debug condition
incorrectly. Usually watchpoints were recognized as breakpoints.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35951 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-26 00:03:53 +00:00
Ingo Weinhold cfefeee3f8 * Changed arch_debug_save_registers() to take an arch-specific structure
arch_debug_registers instead.
* Call arch_debug_save_registers() on all CPUs when entering the kernel
  debugger.
* Added debug_get_debug_registers() to return a specified CPU's saved
  registers.
* x86:
  - Replaced the previous arch_debug_save_registers() implementation. Disabled
    getting the registers via the gdb interface for the time being.
  - Fixed the "sc", "call", and "calling" commands to also work for threads
    running on another CPU.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35907 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-18 17:20:06 +00:00
Ingo Weinhold fe0963a835 Added commands to the page access debugging panic()s.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35904 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-18 16:19:13 +00:00
Ingo Weinhold 085cf27b40 * Added Directory::CreateFile() which can be implemented by file systems to
support file creation.
* Extended open() and open_from() to support O_CREAT to create files.
  open_from() has got an optional "permissions" parameter for that purpose.
* Fixed errno. It would crash when being used. Also changed the POSIX functions
  to return their error code via errno as expected.
* Added writev().
* FAT file system:
  - Added support for reading long file names.
  - Added support for creating files (8.3 name only) and writing to them.
  - Enabled scanning partitions with it.
* Boot loader menu:
  - Enabled the "Reboot" menu item unconditionally.
  - Added "Save syslog from previous session" menu item to the debug menu.
    Currently saving the syslog to FAT32 volumes is supported.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35882 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-16 17:29:58 +00:00
Ingo Weinhold fac2ce3d92 Added ring_buffer_get_vecs() that returns iovecs describing the contents of
the buffer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35880 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-16 17:07:40 +00:00
Ingo Weinhold 7778bccf93 sigsuspend() would previously wake up correctly when a matching signal was
received, but if the signal was in the thread's signal block mask, it would
not be handled. Added thread::sig_temp_enabled, an additional mask of not
blocked signals, which is set by sigsuspend() and evaluated and reset by
handle_signals(). Fixes #5567.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35836 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-13 13:17:40 +00:00
Ingo Weinhold f795376ec6 remove_addr_range() is actually called remove_address_range().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35824 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-12 16:55:42 +00:00
Ingo Weinhold 28a2172c3f kernel:
* The kernel syslog ring buffer is no longer emptied by the syslog sender
  thread. Instead we only drop the oldest data from the buffer when we're
  writing to it and there's not enough free space in it.
  Advantages: We drop old data rather than the most recent data when the buffer
  is full. The "syslog" KDL command has more data available now. So the odds
  are that kernel syslog messages not written to disk yet are at least still
  in the kernel buffer.
* Changed dprintf_no_syslog() semantics: Now it writes to the syslog, but
  doesn't notify the syslog sender thread.

boot loader:
* Added the ring_buffer implementation and a dummy user_memcpy().
* bios_x86: Moved the syslog stuff from serial.{cpp,h} to debug.{cpp.h}.
* Moved the debug options from the "Select safe mode options" menu to a new
  "Select debug options" menu.
* Added option "Enable debug syslog" to the new menu (ATM available on x86
  only). It allocates a 1 MB in-memory buffer for the syslog for this session
  in such a way that it can be accessed by the boot loader after a reset.
* Added item "Display syslog from previous session" to the new menu, doing
  what its name suggests.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35816 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-11 17:46:36 +00:00
Ingo Weinhold 546f4e5e05 * Added create_ring_buffer_etc() which allows to re-create a ring buffer from
a given flat buffer.
* Added ring_buffer_peek() for random position reading from the ring buffer
  without changing its state.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35813 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-11 17:12:21 +00:00
Ingo Weinhold 73a72c42e2 Added get_free_address_range() to get a free range in a given range array.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35801 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-10 18:36:44 +00:00
Ingo Weinhold d40a935560 Boot loader (x86 mmu.cpp):
* Made the page table allocation more flexible. Got rid of sMaxVirtualAddress
  and added new virtual_end address to the architecture specific kernel args.
* Increased the virtual space we reserve for the kernel to 16 MB. That
  should suffice for quite a while. The previous 2 MB were too tight when
  building the kernel with debug info.
* mmu_init(): The way we were translating the BIOS' extended memory map to
  our physical ranges arrays was broken. Small gaps between usable memory
  ranges would be ignored and instead marked allocated. This worked fine for
  the boot loader and during the early kernel initialization, but after the
  VM has been fully set up it frees all physical ranges that have not been
  claimed otherwise. So those ranges could be entered into the free pages
  list and would be used later. This could possibly cause all kinds of weird
  problems, probably including ACPI issues. Now we add only the actually
  usable ranges to our list.

Kernel:
* vm_page_init(): The pages of the ranges between the usable physical memory
  ranges are now marked PAGE_STATE_UNUSED, the allocated ranges
  PAGE_STATE_WIRED.
* unmap_and_free_physical_pages(): Don't free pages marked as unused.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35726 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-02 18:13:06 +00:00
Ingo Weinhold 8b3d3d8a15 Correctly handle cases when a thread single-steps into the kernel as it can
happen on syscalls or "int" instructions. The debug exception handler sets
the thread debug flags B_THREAD_DEBUG_STOP and
B_THREAD_DEBUG_NOTIFY_SINGLE_STEP (new) and lets the thread continue. Before
leaving the kernel the thread is stopped and a single-step notification is
sent. Fixes #3487.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35620 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-25 20:20:16 +00:00
Ingo Weinhold 464d9f1252 Changed object_depot_store() return value to void. It is now always takes
over ownership of the object. Fixes double free introduced in r35605.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35608 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-24 19:04:41 +00:00
Axel Dörfler ff59ce680d * The low resource handler now empties the cache depot's magazines; before,
they were never freed unless the cache was destroyed (I just wondered why
  my system would bury >1G in the magazines).
* Made the magazine capacity variable per cache, ie. for larger objects, it's
  not a good idea to have 64*CPU buffers lying around in the worst case.
* Furthermore, the create_object_cache_etc()/object_depot_init() now have
  arguments for the magazine capacity as well as the maximum number of full
  unused magazines.
* By default, you might want to initialize both to zero, as then some hopefully
  usable defaults are computed. Otherwise (the only current example is the
  vm_page_mapping cache) you can just put in the values you'd want there.
  The page mapping cache uses larger values, as its objects are usually
  allocated and deleted in larger chunks.
* Beware, though, I couldn't test these changes yet as Qemu didn't like to run
  today. I'll test these changes on another machine now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35601 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-24 14:43:20 +00:00
Ingo Weinhold bd7645a12a * Made vm_page::state private and added accessor methods.
* Added kernel tracing for page state transitions.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35538 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-20 15:57:44 +00:00
Ingo Weinhold 8b522fcfe6 Changed ASSERT_[ALWAYS_]PRINT() to add the additional output to the panic()
message instead of printing it before calling panic().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35536 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-20 14:19:52 +00:00
Ingo Weinhold d36b9aef3e Added vm_page::IsMapped() for convenience.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35531 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-20 12:29:42 +00:00
Axel Dörfler 63b69bec3c * Applied patch by Andreas Färber as part of #5319.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35522 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-19 16:44:55 +00:00
Ingo Weinhold dac21d8bfe * map_physical_memory() does now always set a memory type. If none is given (it
needs to be or'ed to the address specification), "uncached" is assumed.
* Set the memory type for the "BIOS" and "DMA" areas to write-back. Not sure, if
  that's correct, but that's what was effectively used on my machines before.
* Changed x86_set_mtrrs() and the CPU module hook to also set the default memory
  type.
* Rewrote the MTRR computation once more:
  - Now we know all used memory ranges, so we are free to extend used ranges
    into unused ones in order to simplify them for MTRR setup.
  - Leverage the subtractive properties of uncached and write-through ranges to
    simplify ranges of any other respectively write-back type.
  - Set the default memory type to write-back, so we don't need MTRRs for the
    RAM ranges.
  - If a new range intersects with an existing one, we no longer just fail.
    Instead we use the strictest requirements implied by the ranges. This fixes
    #5383.

Overall the new algorithm should be sufficient with far less MTRRs than before
(on my desktop machine 4 are used at maximum, while 8 didn't quite suffice
before). A drawback of the current implementation is that it doesn't deal with
the case of running out of MTRRs at all, which might result in some ranges
having weaker caching/memory ordering properties than requested.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35515 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-18 13:52:43 +00:00
Ingo Weinhold 4bb4f79355 Added assert.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35497 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-16 16:49:52 +00:00
Ingo Weinhold 40bb94819e * Removed useless return parameter from vm_remove_all_page_mappings().
* Added vm_clear_page_mapping_accessed_flags() and
  vm_remove_all_page_mappings_if_unaccessed(), which combine the functionality
  of vm_test_map_activation(), vm_clear_map_flags(), and
  vm_remove_all_page_mappings(), thus saving lots of calls to translation map
  methods. The backend is the new method
  VMTranslationMap::ClearAccessedAndModified().
* Started to make use of the cached page queue and changed the meaning of the
  other non-free queues slightly:
  - Active queue: Contains mapped pages that have been used recently.
  - Inactive queue: Contains mapped pages that have not been used recently. Also
    contains unmapped temporary pages.
  - Modified queue: Contains unmapped modified pages.
  - Cached queue: Contains unmapped unmodified pages (LRU sorted).
  Unless we're actually low on memory and actively do paging, modified and
  cached queues only contain non-temporary pages. Cached pages are considered
  quasi free. They still belong to a cache, but since they are unmodified and
  unmapped, they can be freed immediately. And this is what
  vm_page_[try_]reserve_pages() do now when there are no more actually free
  pages at hand. Essentially this means that pages storing cached file data,
  unless mmap()ped, no longer are considered used and don't contribute to page
  pressure. Paging will not happen as long there are enough free + cached pages
  available.
* Reimplemented the page daemon. It no longer scans all pages, but instead works
  the page queues. As long as the free pages situation is harmless, it only
  iterates through the active queue and deactivates pages that have not been
  used recently. When paging occurs it additionally scans the inactive queue and
  frees pages that have not been used recently.
* Changed the page reservation/allocation interface:
  vm_page_[try_]reserve_pages(), vm_page_unreserve_pages(), and
  vm_page_allocate_page() now take a vm_page_reservation structure pointer.
  The reservation functions initialize the structure -- currently consisting
  only of a count member for the number of still reserved pages.
  vm_page_allocate_page() decrements the count and vm_page_unreserve_pages()
  unreserves the remaining pages (if any). Advantages are that reservation/
  unreservation mismatches cannot occur anymore, that vm_page_allocate_page()
  can verify that the caller has indeed a reserved page left, and that there's
  no unnecessary pressure on the free page pool anymore. The only disadvantage
  is that the vm_page_reservation object needs to be passed around a bit.
* Reworked the page reservation implementation:
  - Got rid of sSystemReservedPages and sPageDeficit. Instead
    sUnreservedFreePages now actually contains the number of free pages that
    have not yet been reserved (it cannot become negative anymore) and the new
    sUnsatisfiedPageReservations contains the number of pages that are still
    needed for reservation.
  - Threads waiting for reservations do now add themselves to a waiter queue,
    which is ordered by descending priority (VM priority and thread priority).
    High priority waiters are served first when pages become available.
  Fixes #5328.
* cache_prefetch_vnode(): Would reserve one less page than allocated later, if
  the size wasn't page aligned.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35393 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-03 18:53:52 +00:00
Ingo Weinhold 2735cad982 Added missing include.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35392 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-03 18:47:07 +00:00
Ingo Weinhold cf99b9ab60 Added VMCache::CacheRef() accessor.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35391 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-03 18:46:29 +00:00
Ingo Weinhold c2629ccc6a Patch by "Grey": Small optimization of arch_int_disable_interrupts_inline()
and arch_int_restore_interrupts_inline().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35377 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-02-01 08:55:44 +00:00
Ingo Weinhold e65c400299 * Replaced the vm_page_allocate_page*() "pageState" parameter by a more
general "flags" parameter. It encodes the target state of the page -- so
  that the page isn't unnecessarily put in the wrong page queue first -- a
  flag whether the page should be cleared, and one to indicate whether the
  page should be marked busy.
* Added page state PAGE_STATE_CACHED. Not used yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35333 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-29 15:54:40 +00:00
Ingo Weinhold 72382fa629 * Removed the page state PAGE_STATE_BUSY and instead introduced a vm_page::busy
flag. The obvious advantage is that one can still see what state a page is in
  and even move it between states while being marked busy.
* Removed the vm_page::is_dummy flag. Instead we mark marker pages busy, which
  in all cases has the same effect. Introduced a vm_page_is_dummy() that can
  still check whether a given page is a dummy page.
* vm_page_unreserve_pages(): Before adding to the system reserve make sure
  sUnreservedFreePages is non-negative. Otherwise we'd make nonexisting pages
  available for allocation. steal_pages() still has the same problem and it
  can't be solved that easily.
* map_page(): No longer changes the page state/mark the page unbusy. That's the
  caller's responsibility.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35331 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-29 10:00:45 +00:00
Ingo Weinhold deee8524b7 * Introduced {malloc,memalign,free}_etc() which take an additional "flags"
argument. They replace the previous special-purpose allocation functions
  (malloc_nogrow(), vip_io_request_malloc()).
* Moved the I/O VIP heap to heap.cpp accordingly.
* Added quite a bit of passing around of allocation flags in the VM,
  particularly in the VM*AddressSpace classes.
* Fixed IOBuffer::GetNextVirtualVec(): It was ignoring the VIP flag and always
  allocated on the normal heap.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35316 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-27 12:45:53 +00:00
Ingo Weinhold cff6e9e406 * The system now holds back a small reserve of committable memory and pages. The
memory and page reservation functions have a new "priority" parameter that
  indicates how deep the function may tap into that reserve. The currently
  existing priority levels are "user", "system", and "VIP". The idea is that
  user programs should never be able to cause a state that gets the kernel into
  trouble due to heavy battling for memory. The "VIP" level (not really used
  yet) is intended for allocations that are required to free memory eventually
  (in the page writer). More levels are thinkable in the future, like "user real
  time" or "user system server".
* Added "priority" parameters to several VMCache methods.
* Replaced the map_backing_store() "unmapAddressRange" parameter by a "flags"
  parameter.
* Added area creation flag CREATE_AREA_PRIORITY_VIP and slab allocator flag
  CACHE_PRIORITY_VIP indicating the importance of the request.
* Changed most code to pass the right priorities/flags.

These changes already significantly improve the behavior in low memory
situations. I've tested a bit with 64 MB (virtual) RAM and, while not
particularly fast and responsive, the system remains at least usable under high
memory pressure.
As a side effect the slab allocator can now be used as general memory allocator.
Not done by default yet, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35295 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-26 14:44:58 +00:00
Ingo Weinhold b4e5e49823 MemoryManager:
* Added support to do larger raw allocations (up to one large chunk (128 pages))
  in the slab areas. For an even larger allocation an area is created (haven't
  seen that happen yet, though).
* Added kernel tracing (SLAB_MEMORY_MANAGER_TRACING).
* _FreeArea(): Copy and paste bug: The meta chunks of the to be freed area
  would be added to the free lists instead of being removed from them. This
  would corrupt the lists and also lead to all kinds of misuse of meta chunks.

object caches:
* Implemented CACHE_ALIGN_ON_SIZE. It is no longer set for all small object
  caches, but the block allocator sets it on all power of two size caches.
* object_cache_reserve_internal(): Detect recursion and don't wait in such a
  case. The function could deadlock itself, since
  HashedObjectCache::CreateSlab() does allocate memory, thus potentially
  reentering.
* object_cache_low_memory():
  - I missed some returns when reworking that one in r35254, so the function
    might stop early and also leave the cache in maintenance mode, which would
    cause it to be ignored by object cache resizer and low memory handler from
    that point on.
  - Since ReturnSlab() potentially unlocks, the conditions weren't quite correct
    and too many slabs could be freed.
  - Simplified things a bit.
* object_cache_alloc(): Since object_cache_reserve_internal() does potentially
  unlock the cache, the situation might have changed and their might not be an
  empty slab available, but a partial one. The function would crash.
* Renamed the object cache tracing variable to SLAB_OBJECT_CACHE_TRACING.
* Renamed debugger command "cache_info" to "slab_cache" to avoid confusion with
  the VMCache commands.
* ObjectCache::usage was not maintained anymore since I introduced the
  MemoryManager. object_cache_get_usage() would thus always return 0 and the
  block cache would not be considered cached memory. This was only of
  informational relevance, though.

slab allocator misc.:
* Disable the object depots of block allocator caches for object sizes > 2 KB.
  Allocations of those sizes aren't so common that the object depots yield any
  benefit.
* The slab allocator is now fully self-sufficient. It allocates its bootstrap
  memory from the MemoryManager, and the hash tables for HashedObjectCaches use
  the block allocator instead of the heap, now.
* Added option to use the slab allocator for malloc() and friends
  (USE_SLAB_ALLOCATOR_FOR_MALLOC). Currently disabled. Works in principle and
  has virtually no lock contention. Handling for low memory situations is yet
  missing, though.
* Improved the output of some debugger commands.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35283 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-25 13:46:58 +00:00
Ingo Weinhold 71f65beeb3 Marked CACHE_UNLOCKED_PAGES as unsupported.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35281 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-25 12:22:36 +00:00
Ingo Weinhold b20de45ebd * Added optional allocator template parameter.
* Added optional parameter "void** oldTable" to Resize(). If given the old
  allocation for the table is returned instead of freeing it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35278 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-25 12:18:20 +00:00
Ingo Weinhold 8d1316fd23 Replaced CACHE_DONT_SLEEP by two new flags CACHE_DONT_WAIT_FOR_MEMORY and
CACHE_DONT_LOCK_KERNEL_SPACE. If the former is given, the slab memory manager
does not wait when reserving memory or pages. The latter prevents area
operations. The new flags add a bit of flexibility. E.g. when allocating page
mapping objects for userland areas CACHE_DONT_WAIT_FOR_MEMORY is sufficient,
i.e. the allocation will succeed as long as pages are available.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35246 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-22 21:19:23 +00:00
Ingo Weinhold 86c794e5c1 slab allocator:
* Implemented a more elaborated raw memory allocation backend (MemoryManager).
  We allocate 8 MB areas whose pages we allocate and map when needed. An area is
  divided into equally-sized chunks which form the basic units of allocation. We
  have areas with three possible chunk sizes (small, medium, large), which is
  basically what the ObjectCache implementations were using anyway.
* Added "uint32 flags" parameter to several of the slab allocator's object
  cache and object depot functions. E.g. object_depot_store() potentially wants
  to allocate memory for a magazine. But also in pure freeing functions it
  might eventually become useful to have those flags, since they could end up
  deleting an area, which might not be allowable in all situations. We should
  introduce specific flags to indicate that.
* Reworked the block allocator. Since the MemoryManager allocates block-aligned
  areas, maintains a hash table for lookup, and maps chunks to object caches,
  we can quickly find out which object cache a to be freed allocation belongs
  to and thus don't need the boundary tags anymore.
* Reworked the slab boot strap process. We allocate from the initial area only
  when really necessary, i.e. when the object cache for the respective
  allocation size has not been created yet. A single page is thus sufficient.

other:
* vm_allocate_early(): Added boolean "blockAlign" parameter. If true, the
  semantics is the same as for B_ANY_KERNEL_BLOCK_ADDRESS.
* Use an object cache for page mappings. This significantly reduces the
  contention on the heap bin locks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35232 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-21 23:10:52 +00:00
Ingo Weinhold 5f679d1cd3 Resize(): Added boolean "force" parameter that allows to force setting the
new memory, even if it isn't needed at that time.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35231 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-21 22:16:03 +00:00
Ingo Weinhold 453a2bdd18 Replaced the locking strategy (formerly a recursive lock for the depot and
one for each per CPU store):
* The depot is now protected by a R/W lock combined with a spinlock. It is
  required to either hold read lock + spinlock or just the write lock.
* When accessing the per CPU stores we only need to acquire the read lock
  and disable interrupts. When switching magazines with the depot we
  additionally get the spinlock.
* When allocating a new magazine we do completely unlock.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35200 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-20 13:00:57 +00:00
Ingo Weinhold 5662ae4585 Changed the team shutdown process a bit:
* The threads beside the main thread are killed earlier now (in the new
  team_shutdown_team()), before removing the team from the team hash and from
  its process group. This fixes #5296.
* Use a condition variable instead of a semaphore to wait for the non-main
  threads to die. We notify the condition right after a thread has left the
  team. The semaphore was released by the undertaker.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35196 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-20 09:34:53 +00:00
Ingo Weinhold 7dcd388aa6 Coding style fix.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35180 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-19 20:36:29 +00:00
Ingo Weinhold 825566f82f * Split the slab allocator code into separate source files and C++-ified
things a bit.
* Some style cleanup.
* The object depot does now have a cookie that will be passed to the return
  hook.
* Fixed object_cache_return_object_wrapper() using the new cookie.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35174 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-19 19:13:25 +00:00
Ingo Weinhold 0fc052b47d Moved the definition of the CACHE_ALIGN_ON_SIZE flag to the header and fixed
its value.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35163 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-19 10:17:16 +00:00
Ingo Weinhold a8806e5e0d * Renamed headers/private/kernel/slab/Depot.h to ObjectDepot.h.
* Moved the object depot code to its own source file.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35161 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-19 10:12:48 +00:00
Ingo Weinhold 6379e53e2d vm_page no longer points directly to its containing cache, but rather to a
VMCacheRef object which points to the cache. This allows to optimize
VMCache::MoveAllPages(), since it no longer needs to iterate over all pages
to adjust their cache pointer. It can simple swap the cache refs of the two
caches instead.

Reduces the total -j8 Haiku image build time only marginally. The kernel time
drops almost 10%, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35155 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-19 08:34:14 +00:00
Ingo Weinhold 3632eeedb9 * VMCache: Added a UserData attribute which can be used by the lock holder.
* Added "bool consumerLocked" parameter to VMCache::Unlock() and
  ReleaseRefAndUnlock(). Since Unlock() may cause the cache to be merged with
  a consumer cache, the flag is needed to prevent a deadlock in case the
  caller still holds a lock to the consumer. Hasn't been a problem yet, since
  that situation never occurred.
* VMCacheChainLocker: Reversed unlocking order to bottom-up. The other
  direction could cause a deadlock in case caches would be merged, since the
  locking order would be reversed. The way VMCacheChainLocker was used this
  didn't happen, though.
* fault_get_page(): While copying a page from a lower cache to the top cache,
  we do now unlock all caches but the top one, so we don't unnecessarily
  kill concurrency.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35153 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-19 03:02:11 +00:00
Ingo Weinhold f082f7f019 * Added vm_page::accessed flag. Works analogously to vm_page::modified.
* Reorganized the code for [un]mapping pages:
  - Added new VMTranslationMap::Unmap{Area,Page[s]}() which essentially do what
    vm_unmap_page[s]() did before, just in the architecture specific code, which
    allows for specific optimizations. UnmapArea() is for the special case that
    the complete area is unmapped. Particularly in case the address space is
    deleted, some work can be saved. Several TODOs could be slain.
  - Since they are only used within vm.cpp vm_map_page() and vm_unmap_page[s]()
    are now static and have lost their prefix (and the "preserveModified"
    parameter).
* Added VMTranslationMap::Protect{Page,Area}(). They are just inline wrappers
  for Protect().
* X86VMTranslationMap::Protect(): Make sure not to accidentally clear the
  accessed/dirty flags.
* X86VMTranslationMap::Unmap()/Protect(): Make page table skipping actually
  work. It was only skipping to the next page.
* Adjusted the PPC code to at least compile.

No measurable effect for the -j8 Haiku image build time, though the kernel time
drops minimally.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35089 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-15 22:32:51 +00:00
Ingo Weinhold c6aa013564 Changed VMTranslationMap::Lock()/Unlock() return types to the usual.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35075 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-14 20:44:29 +00:00
Ingo Weinhold bcc2c157a1 Refactored vm_translation_map:
* Pulled the physical page mapping functions out of vm_translation_map into
  a new interface VMPhysicalPageMapper.
* Renamed vm_translation_map to VMTranslationMap and made it a proper C++
  class. The functions in the operations vector have become methods.
* Added class GenericVMPhysicalPageMapper implementing VMPhysicalPageMapper
  as far as possible (without actually writing new code).
* Adjusted the x86 and the PPC specifics accordingly (untested for the
  latter). For the other architectures the build is, I'm afraid, seriously
  broken.

The next steps will modify and extend the VMTranslationMap interface, so that
it will be possible to fix the bugs in vm_unmap_page[s]() and employ
architecture specific optimizations.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35066 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-14 03:26:12 +00:00
Ingo Weinhold 946325051b * Added boolean "alreadyWired" parameter to vm_map_physical_memory().
* ioapic_init(): map_physical_memory() was called for already mapped
  addresses. This worked fine, but only because the x86 page mapping code
  didn't mind.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35059 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-13 22:02:21 +00:00
Ingo Weinhold 3b8c056da0 Should have been part of r35023: Introduction of the vm_page::modified flag.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35024 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-12 01:24:40 +00:00
Ingo Weinhold 3fb2a94dfb * Inline {acquire,release}_spinlock(), when spinlock debugging is disabled.
* Use atomic_{and,or}() instead of atomic_set(), as there are no built-ins
  for the latter.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35021 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-11 22:13:11 +00:00
Ingo Weinhold 451ca8b4b4 PAGE_TYPE_GUARD was unused and for the other two types a simple one bit flag
suffices. Therefore replaced vm_page::type by vm_page::is_dummy.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35013 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-11 19:13:14 +00:00
Ingo Weinhold d7455de2f6 allocate_page_run(): Use temporary lists to store the pages we're allocating.
This makes appending the pages to the active queue more efficient and we
don't need the vm_page::is_cleared bit anymore.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35011 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-11 16:36:31 +00:00
Ingo Weinhold 509f1174ce * Added Size() method.
* Added Debug{First,Next}() methods to allow easy iteration through the
  address spaces in kernel debugger commands.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34978 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-09 20:21:43 +00:00
Ingo Weinhold db28a227c4 Added GetIterator() version that takes a key and returns an iterator to the
respective element (if in the table).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34977 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-09 20:19:29 +00:00
Ingo Weinhold 924a3e5f9b Removed unused <arch>_switch_stack_and_call() and
arch_thread_switch_kstack_and_call().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34971 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-09 15:09:02 +00:00
Michael Lotz 14429e896e Reverted the part of r31520 that made devfs_unpublish_partition() take a raw
device path + child partition name. When a "raw" device is unpublished the node
removal notification triggers the partition and child partitions to be
unpublished/removed. Since in that case the "raw" node is already unpublished
trying to resolve it in devfs_unpublish_partition() again to unpublish the child
partitions would fail, leaving the child partition nodes behind. When a new raw
device would then become available publishing its partitions would fail because
of these left behind nodes, causing bug #4587. Seeing that this code is more
compact and straight forward anyway I don't quite see why it was changed in the
first place.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34967 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-09 03:55:38 +00:00
Ingo Weinhold 77690f288e Added VMCache::SwitchFromReadLock(), atomically unlocking a read lock and
starting to lock the cache.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34936 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-07 15:32:28 +00:00
Ingo Weinhold c4f9831292 Added new mutex_switch_from_read_lock() for unlocking a read lock and
starting to lock a mutex in an atomic operation.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34935 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-07 15:31:29 +00:00
Ingo Weinhold 8ab820f076 VMAddressSpace::Put() is too hot to always write lock the address spaces
table. It is now inline and uses double-checked locking. This reduces the
contention on the lock to insignificant. Total -j8 Haiku image build speedup
is marginal, but the total kernel time drops 12%.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34934 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-07 14:09:56 +00:00
Ingo Weinhold 3cd2094396 * Added new debug feature (DEBUG_PAGE_ACCESS) to detect invalid concurrent
access to a vm_page. It is basically an atomically accessed thread ID field
  in the vm_page structure, which is explicitly set by macros marking the
  critical sections. As a first positive effect I had to review quite a bit of
  code and found several issues.
* Added several TODOs and comments. Some harmless ones, but also a few
  troublesome ones in vm.cpp regarding page unmapping.
* file_cache: PrecacheIO::Prepare()/read_into_cache: Removed superfluous
  vm_page_allocate_page() return value checks. It cannot fail anymore.
* Removed the heavily contended "pages" lock. We use different policies now:
  - sModifiedTemporaryPages is accessed atomically.
  - sPageDeficitLock and sFreePageCondition are protected by a new mutex.
  - The page queues have individual locks (mutexes).
  - Renamed set_page_state_nolock() to set_page_state(). Unless the caller says
    otherwise, it does now lock the affected pages queues itself. Also changed
    the return value to void -- we panic() anyway.
* set_page_state(): Add free/clear pages to the beginning of their respective
  queues as this is more cache-friendly.
* Pages with the states PAGE_STATE_WIRED or PAGE_STATE_UNUSED are no longer
  in any queue. They were in the "active" queue, but there's no good reason
  to have them there. In case we decide to let the page daemon work the queues
  (like FreeBSD) they would just be in the way.
* Pulled the common part of vm_page_allocate_page_run[_no_base]() into a helper
  function. Also fixed a bug I introduced previously: The functions must not
  vm_page_unreserve_pages() on success, since they remove the pages from the
  free/clear queue without decrementing sUnreservedFreePages.
* vm_page_set_state(): Changed return type to void. The function cannot really
  fail and no-one was checking it anyway.
* vm_page_free(), vm_page_set_state(): Added assertion: The page must not be
  free/clear before. This is implied by the policy that no-one is allowed to
  access free/clear pages without holding the respective queue's lock, which is
  not the case at this point. This found the bug fixed in r34912.
* vm_page_requeue(): Added general assertions. panic() when requeuing of
  free/clear pages is requested. Same reason as above.
* vm_clone_area(), B_FULL_LOCK case: Don't map busy pages. The implementation is
  still not correct, though.

My usual -j8 Haiku build test runs another 10% faster, now. The total kernel
time drops about 18%. As hoped the new locks have only a fraction of the old
"pages" lock contention. Other locks lead the "most wanted list" now.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34933 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-07 02:37:05 +00:00
Ingo Weinhold 5800e8a486 * Moved the page management functionality into its own file.
* Renamed page_queue to VMPageQueue and made it a proper C++ class. Use
  DoublyLinkedList instead of own list code.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34874 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-03 17:10:32 +00:00
Ingo Weinhold be7782af0f * Removed DoublyLinkedListLinkImpl constructor. DoublyLinkedListLink doesn't
have one anymore anyway.
* Removed unnecessary setting the list links to NULL after removing a node.
* Replaced "element == NULL" check in Insert() by an assert. This just hid
  potential errors.
* Added Insert{Before,After}() methods and declared the Insert() version
  with the InsertBefore() semantics obsolete.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34873 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-03 17:07:56 +00:00
Ingo Weinhold 355dc6bef4 Inlined several VMCache methods.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34837 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-01 17:09:23 +00:00
Ingo Weinhold 1021fd2826 * agp_gart(): Use vm_page_[un]reserve_pages().
* Removed unused vm_page_allocate_pages().
* Removed now unused (always true) "reserved" parameter from
  vm_page_allocate_page().
* Removed unused (always false) "stealActive" parameter from steal_page().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34836 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-01 16:37:14 +00:00
Axel Dörfler e30dd2c076 * If the VESA driver remaps the frame buffer on init, it will now also make
sure that the kernel's frame buffer console points to the right data.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34835 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-01 14:54:41 +00:00
Ingo Weinhold 2ea2527fe4 R/W lock implementation:
* Changed the rw_lock_{read,write}_unlock() return values to void. They
  returned a value != B_OK only in case of user error and no-one checked them
  anyway.
* Optimized rw_lock_read_[un]lock(). They are inline now and as long as
  there's no contending write locker, they will only perform an atomic_add().
* Changed the semantics of nested locking after acquiring a write lock: Read
  and write locks are counted separately, so read locks no longer implicitly
  become write locks. This does e.g. make degrading a write lock to a read
  lock by way of read_lock + write_unlock (as used in the VM) actually work.

These changes speed up the -j8 Haiku image build on my machine by a few
percent, but more interestingly they reduce the total kernel time by 25 %.
Apparently we get more contention on other locks, now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34830 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-31 17:03:41 +00:00
Ingo Weinhold eb8dc1ebfb * Removed DEBUG_PAGE_CACHE_TRANSITIONS debugging.
* Added VMCache::MovePage() and MoveAllPages() to move pages between caches.
* VMAnonymousCache:
  - _MergeSwapPages(): Avoid doing anything, if neither cache has swapped out
    pages.
  - _MergeSwapPages() does now also remove source cache pages that are
    shadowed by consumer swap pages. This allows us to call _MergeSwapPages()
    before _MergePagesSmallerSource(), save the swap page shadowing check
    there and get rid of the vm_page::merge_swap flag. This is an
    optimization based on the assumption that usually none or only few pages
    are swapped out, so we save a lot of checks.
  - Implemented _MergePagesSmallerConsumer() as an alternative to
    _MergePagesSmallerSource(). The former is used when the source cache has
    more pages than the consumer cache. It iterates over the consumer cache's
    pages, moves them to the source and finally moves all pages back to the
    consumer. The final move is relatively cheap (though unfortunately we
    still have to update all pages' vm_page::cache field), so that overall we
    save iterations of the main loop with the more expensive checks.

The optimizations particularly improve the common fork()+exec*() situations.
fork() uses CoW, which is implemented by putting two new empty caches between
the to be copied area and its cache. exec*() destroys one copy of the area,
its cache and thus causes merging of the other new cache with the old cache.
Since this usually happens in a very short time, the old cache does still
contain many pages and the new cache only few. Previously the many pages were
all checked and moved individually. Now we do that for the few pages instead.

A very extreme example of this situation is the Haiku image build. jam has a
huge heap (> 200 MB) and it fork()s+exec*()s for every action to be executed.
Since during the cache merging the cache is locked, any write access to a
heap page causes jam to block until the cache merging is done. Formerly that
took so long that it killed a lot of parallelism in multi-job builds. That
could be observed particularly well when lots of small actions where executed
(like the Link, XRes, Mimeset, SetType, SetVersion combos when building
executables/libraries/add-ons). Those look dramatically better now.
The overall speed improvement for a -j8 image build on my machine is only
about 15%, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34784 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-27 16:14:13 +00:00
Ingo Weinhold 6afe50d424 * Added assignment operators.
* Some automatic whitespace cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34783 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-27 15:19:17 +00:00
Ingo Weinhold 2e74d74f4f * Added method VMCache::TransferAreas() moving areas from one cache to
another. The code originates from vm_copy_on_write_area(). We now generate
  the VM cache tracing entries, though.
* count_writable_areas() -> VMCache::CountWritableAreas()
* Added debugger command "cache_stack" which is enabled when VM cache tracing
  is enabled. It prints the source caches of a given cache or area at the
  time of a specified tracing entry.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34751 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-22 22:00:35 +00:00
Ingo Weinhold a38f850360 * arch_debug_get_stack_trace():
- Replaced the "userOnly" parameter by a "flags" parameter, that allows to
    specify kernel and userland stack traces individually.
  - x86, m68k: Don't always skip the first frame as that prevents the caller
    from being able to record its own address.
* capture_tracing_stack_trace(): Replaced the "userOnly" parameter by
  "kernelOnly", since one is probably always interested in the kernel stack
  trace, but might not want the userland stack trace.
* Added stack trace support for VM cache kernel tracing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34742 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-22 15:15:07 +00:00
Ingo Weinhold 1fde952c1d DefaultNotificationService:
* Added Lock()/Unlock() for explicit locking by a service user.
* Added NotifyLocked() and made Notify() inline.
* Added HasListeners() so one can check whether there is a listener at all
  before preparing the event message.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34736 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-21 20:56:50 +00:00
Ingo Weinhold 0338371f26 * All scheduler implementations:
- enqueue_in_run_queue() no longer returns whether rescheduling is supposed
    to happen. Instead is sets cpu_ent::invoke_scheduler on the current CPU.
  - reschedule() does now handle cpu_ent::invoke_scheduler_if_idle(). No need
    to let all callers do that.
* thread_unblock[_locked]() no longer return whether rescheduling is supposed
  to happen.
* Got rid of the B_INVOKE_SCHEDULER handling. The interrupt hooks really
  can't know, when it makes sense to reschedule or not.
* Introduced scheduler_reschedule_if_necessary[_locked]() functions for
  checking+invoking the scheduler.
* Some semaphore functions (e.g. delete_sem()) invoke the scheduler now, if
  they wake up anything with greater priority.
  I've also tried to add scheduler invocations in the condition variable and
  mutex/rw_lock code, but that actually has a negative impact on performance,
  probably because it causes too much ping-ponging between threads when
  multiple locking primitives are involved.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34657 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-13 21:18:27 +00:00
Ingo Weinhold b4be7c9021 * Added cpu_ent::running_thread which is maintained by the schedulers.
* simple_smp scheduler: Rewrote the interesting part of
  enqueue_in_run_queue(). It always selects a target CPU for the inserted
  thread, now. If no CPU is idle, the CPU running the thread with the lowest
  priority is chosen. If the thread running on the target CPU has a lower
  priority than the inserted one, it will be asked to reschedule. If that's
  the current CPU, we'll return the correct value (wasn't done before at
  all).
  These changes help reducing latencies. On my machine in an idle system
  playing music DebugAnalyzer shows maximum latencies of about 1 us. I still
  find that a bit much, but it's several orders of magnitude better than
  before. The -j8 Haiku image build time dropped about 10%.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34635 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-11 19:06:57 +00:00
Ingo Weinhold 3533b6597d * Reintroduced the SMP_MSG_RESCHEDULE_IF_IDLE ICI message. This time
implemented by means of an additional member in cpu_ent.
* Removed thread::keep_scheduled and the related functions. The feature
  wasn't used yet and wouldn't have worked as implemented anyway.
* Resurrected an older, SMP aware version of our simple scheduler and made it
  the default instead of the affine scheduler. The latter is in no state to
  be used yet. It causes enormous latencies (I've seen up to 0.1s) even when
  six or seven CPUs were idle at the same time, totally killing parallelism.
  That's also the reason why a -j8 build was slower than a -j2. This is no
  longer the case. On my machine the -j2 build takes about 10% less time now
  and the -j8 build saves another 20%. The latter is not particularly
  impressive (compared with Linux), but that seems to be due to lock
  contention.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34615 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-10 11:54:38 +00:00
Ingo Weinhold 34a48c70ef Added type nanotime_t (an int64 storing a nanoseconds value) and function
system_time_nsecs(), returning the system time in nanoseconds. The function
is only really implemented for x86. For the other architectures
system_time() * 1000 is returned.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34543 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-07 21:43:19 +00:00
Ingo Weinhold 522c2f19d4 * Added a simple mechanism to wait for events to VMCache. WaitForPageEvents()
waits for certain events on a given page, NotifyPageEvents() wakes up
  waiting threads respectively.
* Used the new feature instead of condition variables for waiting on busy
  pages. We save publishing and unpublishing of a condition variable whenever
  a page is marked busy. There's only something to do, if there's at least
  one thread waiting in the list of the respective cache. The general
  assumption is that this is only rarely the case and even if it happens,
  there should be only very few threads.
* Added an apparently missing notification in cache_io(). At least I didn't
  see the reason for it not being there.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34537 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-07 15:42:08 +00:00
Ingo Weinhold 6440406a59 Style changes
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34536 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-07 14:28:56 +00:00
Ingo Weinhold be7328a9f6 Moved VMCache related definitions to <vm/VMCache.h>.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34535 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-07 14:14:21 +00:00
Ingo Weinhold e55886c3a3 Make iteration safe. VMKernelAddressSpace::Next() doesn't like NULL pointers.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34531 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-07 01:56:01 +00:00
Ingo Weinhold 40cd019ea0 * Renamed VMAddressSpace::ResizeArea{Head,Tail}() to ShrinkArea{Head,Tail}()
to clarify that they never enlarge the area.
* Reimplemented VMKernelAddressSpace. It is somewhat inspired by Bonwick's
  vmem resource allocator (though we have different requirements):
  - We consider the complete address space to be divided into contiguous
    ranges of type free, reserved, or area, each range being represented by
    a VMKernelAddressRange object.
  - The range objects are managed in an AVL tree and a doubly linked list
    (the latter only for faster iteration) sorted by address. This provides
    O(log(n)) lookup, insertion and removal.
  - For each power of two size we maintain a list of free ranges of at least
    that size. Thus for the most common case of B_ANY*_ADDRESS area
    allocation, we find a free range in constant time (the rest of the
    processing being O(log(n))) with a rather good fit. This should also
    help avoiding address space fragmentation.
  While the new implementation should be faster, particularly with an
  increasing number of areas, I couldn't measure any difference in the -j2
  haiku build. From a cursory test the -j8 build hasn't tangibly benefitted
  either.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34528 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-06 17:18:04 +00:00
Ingo Weinhold a54549a8cd * AVLTree:
- Renamed to AVLTreeBase and moved it into its own header/source file.
  - Renamed FindClose() to FindClosest().
  - Added CheckTree() method for debugging purposes. It checks the validity
    of the tree.
* Added a templatized class AVLTree which doesn't offer a map-like interface
  like AVLTreeMap, but rather one similar to BOpenHashMap and SplayTree. It
  is more convenient to use, if one wants to store objects that already
  contain the key.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34526 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-06 15:59:37 +00:00
Ingo Weinhold 4fb60da357 Removed the DoublyLinkedListLink constructor and destructor. They are not
necessary and prevent the structures from being used in a union.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34525 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-06 15:47:34 +00:00
Ingo Weinhold 2c1886aeae * Added VMArea subclasses VM{Kernel,User}Area and moved the address space list
link to them.
* VM{Kernel,User}AddressSpace manage the respective VMArea subclass now, and
  VMAddressSpace has grown factory methods {Create,Delete}Area.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34493 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-04 17:07:16 +00:00
Ingo Weinhold e2518ddbb1 Made VMAddressSpace an abstract base class and moved the area management into
new derived classes VM{Kernel,User}AddressSpace. Currently those are
identical, but that will change.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34492 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-04 14:45:08 +00:00
Ingo Weinhold 38a97b2c36 Moved all knowledge of reserved areas from vm.cpp to VMAddressSpace. It's a
pure address space feature, so it should be handled there.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34491 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-04 13:33:25 +00:00
Ingo Weinhold f69032f22b * Added VMAddressSpace::ResizeArea{Head,Tail}() to adjust an area's base
and size.
* Made VMArea::Set{Base,Size}() private and made VMAddressSpace a friend.
  In vm.cpp the new VMAddressSpace::ResizeArea{Head,Tail}() are used
  instead.
Finally all address space changes happen in VMAddressSpace only. *phew*
Now it's ready to be thoroughly butchered. :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34467 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-03 15:21:18 +00:00
Ingo Weinhold bbd97b4bb4 Made the VMArea fields base and size private and added accessors instead.
This makes it more explicit where the fields are modified.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34464 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-03 14:18:24 +00:00
Colin Günther af983c175d Coding style cleanups. Thanks axeld.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34462 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-03 13:05:39 +00:00
Ingo Weinhold f5251d5b60 Added comment regarding use restriction.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34460 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-03 12:47:29 +00:00
Ingo Weinhold 35d940014e * Changed the address space area list to doubly linked. The reason is to
simplify migration of the area management, but as a side effect, it also
  makes area deletion O(1) (instead of O(n), n == number of areas in the
  address space).
* Moved more area management functionality from vm.cpp to VMAddressSpace and
  VMArea structure creation to VMArea. Made the list and list link members
  itself private.
* VMAddressSpace tracks its amount of free space, now. This also replaces
  the previous mechanism to do that only for the kernel address space. It
  was broken anyway, since delete_area() subtracted the area size instead of
  adding it.
* vm_free_unused_boot_loader_range():
  - lastEnd could be set to a value < start, which could cause memory
    outside of the given range to be unmapped. Haven't checked whether this
    could happen in practice -- if so, it would be seriously unhealthy.
  - The range between the end of the last area in the range and the end of
    the range would never be freed.
  - Fixed potential integer overflows when computing addresses.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34459 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-03 12:41:11 +00:00
Colin Günther 1581b764e0 * Adding static Notify{One,All} functions. This allows a cleaner implementation
of the condition variable and synchronization subsystem of the freebsd compat
  layer which will be committed next.
* Also there was a discussion about adding these functions on the commit
  mailing list. The mail in http://www.freelists.org/post/haiku-commits/r34395-in-haikutrunksrclibscompatfreebsd-network-compatsys,3
  is a good sum up of it (need to scroll somewhat down, though).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34458 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-03 12:24:17 +00:00
Ingo Weinhold f34a1dd5d7 Created VMArea.{h,cpp} and moved VMArea and the global area hash table (new
class VMAreaHash) there.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34450 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-02 19:55:59 +00:00
Ingo Weinhold e50cf8765b * Moved the VM headers into subdirectory vm/.
* Renamed vm_cache.h/vm_address_space.h to VMCache.h/VMAddressSpace.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34449 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-02 18:05:10 +00:00
Ingo Weinhold 90d870c155 * Moved VMAddressSpace definition to vm_address_space.h.
* "Classified" VMAddressSpace, i.e. turned the vm_address_space_*() functions
  into methods, made all attributes (but "areas") private, and added
  accessors.
* Also turned the vm.cpp functions vm_area_lookup() and
  remove_area_from_address_space() into VMAddressSpace methods. The rest of
  the area management functionality will follow soon.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34447 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-02 16:12:15 +00:00
Ingo Weinhold fc7864091e Attempt at allowing to use C++ structures in C only code: We use the
CreateAsmStructOffsetsHeader mechanism to generate a header with macros
defined to the sizes of the structures we're interested in and when compiling
in C mode define the structures as "struct { char bytes[size]; }".
It works in principle, but due to how jam works, one would have to specify the
dependency to the generated header for all sources that include it directly or
indirectly.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34441 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-02 10:56:10 +00:00
Ingo Weinhold a477e3cf20 Finished renaming of vm_cache to VMCache.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34424 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-01 17:45:55 +00:00
Ingo Weinhold a99eb6b56f vm_area -> VMArea
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34423 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-01 17:40:04 +00:00
Ingo Weinhold b0db552cd9 Renamed vm_address_space to VMAddressSpace.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34422 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-01 17:27:09 +00:00
Axel Dörfler 8de72f9d58 * Cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34416 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-01 16:32:48 +00:00
Ingo Weinhold e182b46db6 Since there were no further complaints: Added mutex_lock_with_timeout().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34403 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-01 09:38:34 +00:00
Axel Dörfler b8a73945cf * The kernel's address space is now also a resource that is known to the low
resource manager.
* Could be drastically improved, though, by taking the fragmentation into
  account.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34309 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-27 13:03:28 +00:00
Axel Dörfler 486fffdaaf * Forgot to add linkat(), this really closes #4928 now.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34289 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-26 16:30:16 +00:00
Axel Dörfler fb2500da15 * Added missing AT_EACCESS.
* Implemented renameat(), faccessat(), fchownat(), fchmodat(), and mkfifoat().
* Added stub for mknodat().
* The kernel backend for faccessat() does not yet differentiate between
  effective and real user/group IDs, though.
* Removed B_ENABLE_INCOMPLETE_POSIX_AT_SUPPORT, as we now support everything
  (more or less). This also closes ticket #4928.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34288 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-26 16:17:17 +00:00
Axel Dörfler 1ba04177d3 * load_image() now has exec() semantics wrt file descriptors; before each team
would always inherit them all, causing quite a number of open files.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34247 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-25 16:16:22 +00:00
Axel Dörfler 5472c0c23e * The VESA driver now tries to find the PCI card that it is controlling by
checking the physical frame buffer location.
* This allows us to map the whole frame buffer at once, which means there is no
  need anymore to remap the memory on mode change.
* Also, this will ease the burden of the MTRRs, as the memory size will be
  properly aligned.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34206 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-24 15:26:52 +00:00
Ingo Weinhold bb163c0289 * Added a set_mtrrs() hook to x86_cpu_module_info, which is supposed to set
all MTRRs at once.
* Added a respective x86_set_mtrrs() kernel function.
* x86 CPU module:
  - Implemented the new hook.
  - Prefixed most debug output with the CPU index. Otherwise it gets quite
    confusing with multiple CPUs.
  - generic_init_mtrrs(): No longer clear all MTRRs, if they are already
    enabled. This lets us benefit from the BIOS's setup until we install our
    own -- otherwise with caching disabled things are *really* slow.
* arch_vm.cpp: Completely rewrote the MTRR handling as the old one was not
  only slow (O(2^n)), but also broken (resulting in incorrect setups (e.g.
  with cachable ranges larger than requested)), and not working by design for
  certain cases (subtractive setups intersecting ranges added later).
  Now we maintain an array with the successfully set ranges. When a new range
  is added, we recompute the complete MTRR setup as we need to. The new
  algorithm analyzing the ranges has linear complexity and also handles range
  base addresses with an alignment not matching the range size (e.g. a range
  at address 0x1000 with size 0x2000) and joining of adjacent/overlapping
  ranges of the same type.

This fixes the slow graphics on my 4 GB machine (though unfortunately the
8 MTRRs aren't enough to fully cover the complete frame buffer (about 35
pixel lines remain uncachable), but that can't be helped without rounding up
the frame buffer size, for which we don't have enough information). It might
also fix #1823.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34197 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-23 15:06:08 +00:00
Ingo Weinhold 4d7a736bbf Some more style cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34156 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-20 13:57:20 +00:00
Ingo Weinhold 0d1fab522b * Added flag KMESSAGE_CLONE_BUFFER, which will cause buffer passed to SetTo()
to be cloned.
* Added "flags" parameter to the SetTo(const void*,...) version.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34155 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-20 13:52:23 +00:00
Ingo Weinhold 395fb0895f Style cleanup. No functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34152 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-20 11:04:12 +00:00
Ingo Weinhold 9837ec16c8 Fixed spelling.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34144 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-20 07:10:23 +00:00
Axel Dörfler 01ce3f26d2 * Cleanup, no functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33951 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-08 17:31:39 +00:00
Ingo Weinhold 8d24cfc6c2 * Added Iterator::NextValuePointer().
* Made reference returned by _GetKey() const. That's sufficient.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33898 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-05 17:18:12 +00:00
Colin Günther 8ac8b52a03 Removed part about where RadixBitmap is currently used, because the FreeBSD compat layer uses it, too. I think it is prone to inconsistency managing a usage list in the header file.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33860 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-01 20:37:03 +00:00
Axel Dörfler d337132b41 * Coding style cleanup, no functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33792 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-27 18:22:39 +00:00
Axel Dörfler 86a999adfb * delete_owned_ports() no longer scans the whole port array for ports belonging
to the owning team.
* Instead, the team now maintains a list containing the ports it owns.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33771 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-26 13:34:43 +00:00
Axel Dörfler ddbe12007a * Semaphores are now put into the team struct in a doubly linked list.
* This makes sem_delete_owned_sems() a lot more efficient; before it would need
  to scan the entire semaphore table.
* This speeds up the test build of the kernel by another 2 seconds (with
  KDEBUG=2) on my laptop.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33743 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-23 02:06:51 +00:00
Axel Dörfler f28dd36b82 * The alphabet is obviously hard, moved some tracing defines at their
(hopefully) correct place.
* It seems to be even harder to understand basic locking primitives: when you
  think about it, it shouldn't surprise you that conditional variables never
  return B_WOULD_BLOCK. This fixes gdb again.
* Added tracing support to the ports subsystem.
* get_port_message() will now resize the port heap if needed (but will also
  take timeouts into account while doing so, more or less). The initial port
  space is 4MB (as before), the growth rate is the same, and the system wide
  limit is arbitrarily set to 64 MB (all swappable). A team limit has been set
  to 8 MB, but is not enforced yet. Since ports are using up address space in
  the kernel, those seems to be proper limits.
* This also fixes a strange, and rare lockup where the mouse cursor would still
  move, but everything else would basically hang, but look perfectly normal from
  KDL on the first look. As recently happened on Brecht's laptop, and debugged
  by mmlr and me: the cbuf space got used up when lots of windows wanted to
  redraw after a workspace switch. The app_server wouldn't answer anymore to
  client requests, but thought it would have done so, as LinkSender::Flush()
  doesn't care if it got a B_NO_MEMORY (the ports will now block until memory
  is available if possible, so that should not be a problem anymore).
* Improved "port" KDL command, it now also prints the messages in the port.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33735 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-22 23:14:10 +00:00
Axel Dörfler e8885f2097 Basically rewrote the ports subsystem to use:
* its own heap allocator instead of cbuf - this makes cbuf superfluous, and I
  therefore removed it from the kernel. The heap is swappable, so lifts the
  kernel's resource usage a bit. In the future, the heap should grow as well;
  right now it should be at least as good as before.
* it no longer uses spinlocks, but just mutexes now for better scalability - it
  was not usable with interrupts turned off anyway (due to its semaphore usage).
* it no longer uses semaphores, but condition variables.
* Needed to move the port initialization to a later point, as swappable memory
  wasn't usable that early.
* All ports test are still passing, hopefully I didn't mess anything up :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33728 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-22 13:24:12 +00:00
Axel Dörfler e0aad96f94 * Allow to use symbols as variables (prefixed with '@'). Now only tab completion
for variable names is missing B-}


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33723 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-22 11:44:29 +00:00
Axel Dörfler 68d9d8809b * Just use the heap instead of cbuf for send_data().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33722 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-22 11:42:51 +00:00
Michael Lotz 4bee71c211 * Implement per-CPU heaps. They only get enabled in case there's enough memory.
* Allow an allocator to be created on the heap to allow for non-locked
  allocators to be created.
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33721 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-22 08:57:34 +00:00
Michael Lotz 5ee1f125e5 Make use of the wait status field so it can be provided in Notify() and then
read out in the ConditionVariableEntry::WaitStatus(). That way you can notify
with a specific status that can be read out on the other end.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33718 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-21 23:44:59 +00:00
François Revol 546376e654 Typo.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33671 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-19 23:23:33 +00:00
François Revol 7c595f3353 ARM920T specific definitions (not done yet).
Board config file for the FreeRunner.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33667 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-19 21:13:46 +00:00
Axel Dörfler 39e3058e5b * Reverted r33643 - while it doubled the performance for my test case (with
high contention of the read lock (I experimented with the VM page mapping
  lock)), it actually hurt the compile performance pretty obviously.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33647 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-19 00:16:54 +00:00
Axel Dörfler 22ea088498 * The rw_lock is now using a mutex to protect its reader/writer counts. This
makes the reader case a lot less expensive, and should relieve the thread
  spinlock contention a bit.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33643 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-18 19:52:09 +00:00
Axel Dörfler b2a7fcb404 * Added an arch_debug_stack_trace() function that is called from the KDL loop
in case there aren't any KDL commands available yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33642 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-18 19:50:13 +00:00
Axel Dörfler 9b912c694a * Cleanup, no functional change - this is now a pure C++ header.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33596 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-15 10:13:02 +00:00
Axel Dörfler 3066f3dbf8 * Reverted r33547, this closes bug #4782 - this is obviously a regression in
GCC4.
* Adapted code accordingly.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33592 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-15 07:48:31 +00:00
Axel Dörfler b74a098352 * Got rid of the duplicated functionalities provided by RWLocker.cpp, and
Locker.cpp.
* The services are now using recursive_locks, and rw_locks instead.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33548 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-12 14:29:05 +00:00
Axel Dörfler 4baa865937 * Added casts to the *_INITIALIZER macros, so that they can also be used in
a member constructor list.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33547 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-12 14:27:02 +00:00
Michael Lotz 7ebd7cfc40 Add a vm_page_allocate_page_run_no_base. It bases its search on the pages found
in the free and/or clear queue. This performs better in the case where only few
pages are free/clear but performs worse in the case where there are a lot of
usable pages. It's not used anywhere but it might come in handy one time.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33527 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-11 16:55:21 +00:00
Michael Lotz 44778a8a28 Introduce vm_map_physical_memory_vecs. It is like vm_map_physical_memory but
takes a list of iovecs describing the physical pages to be mapped. With it one
can map a set of physically disjoint pages into one linear virtual range. This
is a private API right now, but we might want to make it public as
map_physical_memory_vecs alongside map_physical_memory.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33523 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-11 16:48:03 +00:00
Michael Lotz 1af7d11504 * Rework page writing to combine page writes where possible. For now the pages
are required to be physically contiguos, which should be reworked to put them
  into seperate iovecs. Still this manages to combine a great deal of page
  writes into larger bursts already. Reduces the amount of IO requests being
  scheduled (and greatly benefits media where page wise writes are slow when
  they are accessed through a non-IOScheduler path, i.e. USB mass storage until
  that is properly implemented).
* Abstracted per page page writing tasks into a PageWriteWrapper class.
* Abstracted per transfer page writing tasks into PageWriteTransfer class which
  formerly was the PageWriterCallback.
* Use both classes from the PageWriterRun and from
  vm_page_write_modified_page_range to remove code duplication.
* Adjusted synchronous VMAnonymousCache::Write() to cope correctly with larger
  iovecs and more than one iovec. It assumed that there was exactly one page per
  vector previously.
* Introduced MaxPagesPerWrite() and MaxPagesPerAsyncWrite() to VMCache to allow
  a cache to specify restricitions. VMAnonymousCache does restrict the max pages
  to 1 for WriteAsync right now as I didn't feel like reworking that one to cope
  with non single page writes just yet.
* Pulled out PageWriteTransfer methods for better readability.
* Some typo fixes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33507 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-10 22:37:26 +00:00
Michael Lotz 793d0f340d Add a nogrow variant for new[] as well.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33506 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-10 22:29:11 +00:00
Ingo Weinhold a9689e8492 * VFS:
- Fixed vfs_get_vnode_from_fd() return type.
  - Added vfs_open_vnode().
  - Added a "bool traverseLeafLink" parameter to vfs_get_fs_node_from_path().
    It was always resolving symlinks.
* device manager/devfs:
  - devfs: get_node_for_path() no longer resolves leaf symlinks. That still
    doesn't help with file disk devices, as creating partition wouldn't work
    anyway.
  - Pulled the module-related implementation part of BaseDevice into new class
    AbstractModuleDevice and made all methods of BaseDevice virtual. Small
    adjustments to devfs to be happy with the new BaseDevice interface.
  - Added BaseDevice subclass FileDevice, which maps the interface to a file's
    file descriptor. Still got a few TODOs, but should basically work.
  - Use FileDevice for publishing file disk devices in devfs. Now those do
    actually work, though there's some BFS trouble with one of the images I
    tested.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33385 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-01 03:06:34 +00:00
Ingo Weinhold be51dd0f4c Added debug_strlcpy() for use in the kernel debugger.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33380 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-10-01 03:02:34 +00:00
François Revol 858a20cab8 Patch by Vincent Duvert:
Remove the 4 cores limit at boot, and fix the allocator to handle 8 cores.
There are still performance problems, but this allows booting with 8 cores.
WARNING: since this changes x86 platform kernel args, you really don't want to update haiku_loader and kernel_x86 separately!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33349 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-09-29 13:07:10 +00:00
Stefano Ceccherini ea40a61a84 Some big changes, still not working on my laptop, since hpet interrupts
aren't routed correctly over the 8259, it seems.
- Removed passing the hpet_regs around, since there's a static variable.
- Added lots of debug dprintfs.
- Fixed setting the timer interrupt to edge
- Timer is initialized once.
- Use the timer 0 instead of 2.
- Renamed register definitions to be more readable
- Use 64 bits registers and unions where applicable.
- Other things I don't remember


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33345 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-09-29 08:36:36 +00:00
Stefano Ceccherini 8593bcad87 Use the hpet defines in the source.
Also shortened some defines using "TN" instead of "TIMER". It's also
the same scheme used in the specs


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33334 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-09-28 13:14:16 +00:00
Stefano Ceccherini 6e53324663 Added more HPET defines, not yet used in the source.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33331 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-09-28 05:10:43 +00:00
Ingo Weinhold ac106be534 Inherit the disable_debugger() flag to a fork()ed child. load_image() doesn't
-- I'm undecided whether it should, too. Fixes #4642.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33330 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-09-28 02:54:38 +00:00
Stefano Ceccherini 3cafc2ec3e Update comments
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33316 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-09-27 08:50:42 +00:00
Rene Gollent 4e79886a59 Fix gcc4 build.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33294 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-09-25 14:36:26 +00:00
Stefano Ceccherini d54e62b2c8 Added dumping the timer configuration, and the possibility to use any of
the hpet timer, not just the first 3.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33285 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-09-25 05:08:22 +00:00
Stefano Ceccherini cd1352fe63 Fix endianess problem: the period and capabilities bits were reversed in the hpet registers
struct definition.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33274 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-09-24 22:06:02 +00:00
Michael Lotz 0f4242de40 Implement a vm_block_address_range() function which creates an area with no
mapped pages and a non-read and non-write protection to block a certain address
range from being used by anything.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33030 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-09-10 01:40:46 +00:00
Stephan Aßmus 74e8797f5e Fixed the build. Axel is probably going to commit the cleaned up header soon.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32893 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-09-01 15:14:57 +00:00
Jonas Sundström 893988af82 Added and modified kernel stubs and headers for arch mipsel. Correctness not included.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32621 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-23 02:52:09 +00:00
Jonas Sundström 8e8130d1f0 Adding routerboard_mipsel platform stubs and linker script.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32594 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-22 01:48:18 +00:00
Michael Lotz 29bd9bfd7d Remove SMP_MSG_RESCHEDULE_IF_IDLE as it is not used anymore.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32574 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-21 16:14:18 +00:00
Rene Gollent 009ccc2962 anevilyak+mmlr:
* scheduler_enqueue_in_runqueue() now allows the scheduler to return a hint as to whether a reschedule is desirable or not. This is used in a few other places in order to relegate scheduling decisions entirely to the scheduler rather than the priority hacks previously used. There are probably other places in the kernel that could now make use of that information to more intelligently call reschedule() though.
* Switch over the default scheduler to scheduler_affine().



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32554 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-21 04:11:40 +00:00
Michael Lotz 152132f08a mmlr+anevilyak:
* Keep track of the currently running threads.
* Make use of that info to decide if a thread that becomes ready should preempt
  the running thread.
* If we should preempt we send the target CPU a reschedule message.
* This preemption strategy makes keeping track of idle CPUs by means of a bitmap
  superflous and it is therefore removed.
* Right now only other CPUs are preempted though, not the current one.
* Add missing initialization of the quantum tracking code.
* Do not extend the quantum of the idle thread based quantum tracking as we want
  it to not run longer than necessary. Once the preemption works completely
  adding a quantum timer for the idle thread will become unnecessary though.
* Fix thread stealing code, it did missed the last thread in the run queue.
* When stealing, try to steal the highest priority thread that is currently
  waiting by taking priorities into account when finding the target run queue.
* Simplify stealing code a bit as well.
* Minor cleanups.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32503 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-19 03:19:17 +00:00
François Revol 47eb033980 [GSoC] [ARM] Patch by Johannes Wischert.
Revert back start of kernel space to the usual place, no need to differ from other archs here.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32401 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-14 22:33:39 +00:00
François Revol 7db9fbfe80 Factor out the splash image display logic too.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32395 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-14 20:51:29 +00:00
François Revol 0573d397e1 Factor out the RLE and blitting functions from bios_ia32 to platform/generic/ so it can be reused by other platforms.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32383 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-14 18:15:44 +00:00
François Revol b044ca6a19 "Haiku" -> "MIT" license.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32381 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-14 18:10:37 +00:00
François Revol cf4cc90528 Fix (c) style; and use "MIT" since there is no "Haiku" license by itself.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32380 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-14 18:09:38 +00:00
François Revol 3f6f17cf36 [ARM]
Start of framebuffer initialization for the Verdex board.
For now it points to the data section as framebuffer for testing and shows an RGB pattern.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32352 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-14 12:40:16 +00:00
Axel Dörfler bb693d7764 * Added VESA capabilities field to the kernel args.
* The vesa driver no longer uses VGA programming if the chip does not support
  VGA compatibility.
* The VESA driver now tries to set the DAC to 8 bits per color gun.
* In VESA modes, the driver no longer tries to use VGA programming; introduced
  the new vesa_set_indexed_colors() that is now used for palette programming.
  This should fix wrong colors of 8 bit BWindowScreen users with VESA on real
  hardware (emulators usually didn't mind either way).
* Note that the app_server needs to maintain a palette per 8 bit screen, as
  right now, the colors are garbled after a workspace switch. Stefano, are you
  looking into that already?


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32347 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-14 09:49:28 +00:00
François Revol 715a9925f1 [ARM]
Move ARM MMU definitions to a separate header file.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32332 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-13 21:09:48 +00:00
François Revol ffb5971f0d [GSoC] [ARM] Patch by Johannes Wischert.
- fix header guard,
- add needed fields to arch kernel args to pass mmu info.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32329 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-13 18:57:36 +00:00
François Revol 8a07056253 [ARM]
Identify cpus more precisely.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32315 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-13 14:45:06 +00:00
Axel Dörfler 8166e6e477 * Enlarged kernel_args array even more, as network boot needs this with all the
extra kernel drivers.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32303 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-13 11:07:57 +00:00
François Revol 01c8294cc7 [ARM]
- don't clobber the parameter regs in the entry point,
- fix entry point address for netbsd loader emulation,
- added a gUImage global to point to the uimage blob with the tgz,
- added tgz info to platform stage2 args,
- add simple uimage support, just dumps the header and gets the nth blob in the image, (seems we have a bug in the math code, some infos don't print),
- made devices.cpp use them to publish the MemoryDisk,
- add an haiku_loader_nbsd.ub target which puts both the loader and kernel_arm for now (need to replace with the tgz).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32295 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-13 05:28:30 +00:00
François Revol b6d77b2e49 - cleanup,
- assign (c) to Haiku Inc as it's just empty anyway.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32292 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-13 01:24:44 +00:00
François Revol f875744d56 [ARM]
Remove duplicate header.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32202 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-08 02:26:01 +00:00
François Revol a4d5e47408 [ARM]
debug UART is [0] on Verdex.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32200 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-08 02:18:29 +00:00
François Revol afd3d7cbaa [ARM]
Map UARTs to the cpu specific addresses.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32198 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-08 01:05:49 +00:00
François Revol 15317caafe [ARM]
- moved board/ folder around again, it probably belongs only to kernel stuff,
- added board_config.h templates for gumstix boards.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32197 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-08 00:35:48 +00:00
François Revol 98977abc9b Fix m68k build, still unimplemented.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32102 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-03 21:17:03 +00:00
François Revol 56c6c0fefb - introduced an "argumetns" field in stage2_args to hold command line args from chaining loader,
- added some multiboot support code:
	- dump some of the passed info,
	- parse command line (skip the 'kernel' name and pass the rest to stage2_args.arguments),
- added an add_stage2_driver_settings() function which takes stage2_args.arguments and translates it into safe mode driver settings, a bit dumb for now.
This allows using qemu -kernel haiku_loader -append 'debug_screen true' and get debug output without having to enter the menu (once multiboot info is used to determine the boot device too).
The idea is to allow passing driver settings and using them to pass extra stuff (like 'force_keymap fr' and other stuff for demo), and to help automate tests ('run_test /bin/sometest').
This should answer Axel's question :)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32076 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-03 14:39:41 +00:00
Michael Lotz 255c9104e5 * Rework the heap locking strategy. Use a read-write lock for the area lock to
allow for more parallelism. Also introduce seperate locks for the bins and
  for page allocation. This greatly reduces lock contention and reduces the
  duration the locks are held due to them overall protecting less code. Now only
  allocations of the same size hitting the same allocator or allocating larger
  chunks of memory should block. Previously, basically any allocation and also
  free would be mutually exclusive, making it scale pretty badely.
* Added memalign_nogrow(). As it uses heap_memalign() anyway, there's no real
  reason not to allow for an alignment.
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32074 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-03 13:59:45 +00:00
Ingo Weinhold ea2abd110b * Renamed the ROUNDOWN macro to ROUNDDOWN. Also changed the implementation of
ROUNDUP to use '*' and '/' -- the compiler will optimize that for powers of
  two anyway and this implementation works for other numbers as well.
* The thread::fault_handler use in C[++] code was broken with gcc 4. At least
  when other functions were invoked. Trying to trick the compiler wasn't a
  particularly good idea anyway, since the next compiler version could break
  the trick again. So the general policy is to use the fault handlers only in
  assembly code where we have full control. Changed that for x86 (save for the
  vm86 mode, which has a similar mechanism), but not for the other
  architectures.
* Introduced fault_handler, fault_handler_stack_pointer, and fault_jump_buffer
  fields in the cpu_ent structure, which must be used instead of
  thread::fault_handler in the kernel debugger. Consequently user_memcpy() must
  not be used in the kernel debugger either. Introduced a debug_memcpy()
  instead.
* Introduced debug_call_with_fault_handler() function which calls a function
  in a setjmp() and fault handler context. The architecture specific backend
  arch_debug_call_with_fault_handler() has only been implemented for x86 yet.
* Introduced debug_is_kernel_memory_accessible() for use in the kernel
  debugger. It determines whether a range of memory can be accessed in the
  way specified. The architecture specific back end
  arch_vm_translation_map_is_kernel_page_accessible() has only been implemented
  for x86 yet.
* Added arch_debug_unset_current_thread() (only implemented for x86) to unset
  the current thread pointer in the kernel debugger. When entering the kernel
  debugger we do some basic sanity checks of the currently set thread structure
  and unset it, if they fail. This allows certain commands (most importantly
  the stack trace command) to avoid accessing the thread structure.
* x86: When handling a double fault, we do now install a special handler for
  page faults. This allows us to gracefully catch faulting commands, even if
  e.g. the thread structure is toast.

We are now in much better shape to deal with double faults. Hopefully avoiding
the triple faults that some people have been experiencing on their hardware
and ideally even allowing to use the kernel debugger normally.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32073 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-03 12:39:56 +00:00
François Revol 4b8d0e6856 Some ppc fixes for #4115, patch by kallisti5 (without the #ifdef _BOOT_MODE):
- stubbed out arch_cpu_init_percpu(),
- make atomic ops declarations extern "C",
- move calls to [i]sync inside the asm code that needs it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32067 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-03 10:10:22 +00:00
Ingo Weinhold 671a2442d9 More work towards making our double fault handler less triple fault prone:
* SMP:
  - Added smp_send_broadcast_ici_interrupts_disabled(), which is basically
    equivalent to smp_send_broadcast_ici(), but is only called with interrupts
    disabled and gets the CPU index, so it doesn't have to use
    smp_get_current_cpu() (which dereferences the current thread).
  - Added cpu index parameter to smp_intercpu_int_handler().
* x86:
  - arch_int.c -> arch_int.cpp
  - Set up an IDT per CPU. We were using a single IDT for all CPUs, but that
    can't work, since we need different tasks for the double fault interrupt
    vector.
  - Set the per CPU double fault task gates correctly.
  - Renamed set_intr_gate() to set_interrupt_gate and set_system_gate() to
    set_trap_gate() and documented them a bit.
  - Renamed double_fault_exception() x86_double_fault_exception() and fixed
    it not to use smp_get_current_cpu(). Instead we have the new
    x86_double_fault_get_cpu() that deducts the CPU index from the used stack.
  - Fixed the double_fault interrupt handler: It no longer calls int_bottom to
    avoid accessing the current thread.
* debug.cpp:
  - Introduced explicit debug_double_fault() to enter the kernel debugger from
    a double fault handler.
  - Avoid using smp_get_current_cpu().
  - Don't use kprintf() before sDebuggerOnCPU is set. Otherwise
    acquire_spinlock() is invoked by arch_debug_serial_puts().

Things look a bit better when the current thread pointer is broken -- we run
into kernel_debugger_loop() and successfully print the "Welcome to KDL"
message -- but we still dereference the thread pointer afterwards, so that we
don't get a usable kernel debugger yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32050 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-08-01 01:53:54 +00:00
Ingo Weinhold cc77aba101 * Allocate a separate double fault stack for each CPU.
* Added x86_double_fault_get_cpu(), a save way to get the CPU index when in
  the double fault handler. smp_get_current_cpu() requires at least a somewhat
  intact thread structure, so we rather want to avoid it when handling a double
  fault. There are a lot more of those dependencies in the KDL entry code.
  Working on it...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32028 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-31 16:14:18 +00:00
Ingo Weinhold 3fccf0679f C++ified the code. Introduced new trace entry flags, which will eventually be
used to mark entries after recovering a tracing log from a previous session.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31991 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-30 19:50:50 +00:00
Ingo Weinhold 213d2d8f9d Added syscall _kern_kernel_debugger() to enter the kernel debugger.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31965 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-30 12:35:42 +00:00
Ingo Weinhold d3b44ccb14 Added explicit physical address parameter to vm_create_anonymous_area() and
create_area_etc(). 0 for the default behavior.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31941 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-29 21:30:35 +00:00
Ingo Weinhold 069b477dd7 * Introduced CREATE_AREA_DONT_CLEAR create_area_etc() flag, which allows the
call to fetch non-clear pages.
* B_PHYSICAL_BASE_ADDRESS does now imply B_CONTIGUOUS.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31932 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-29 18:57:21 +00:00
Axel Dörfler 8ae594ffd4 * Introduced dedicated syscalls for the deprecated BeOS fs_attr API. Before,
each attribute access needed 3 syscalls, now only one as it should.
* Renamed the new Haiku call fs_open_attr() to fs_fopen_attr(), and added a new
  function fs_open_attr() that takes a path (same semantics as the
  fs_[f]open_attr_dir() functions already present in BeOS).
* Merged former _kern_open_attr(), and _kern_create_attr() into one syscall.
* Cleaned up vfs.h.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31881 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-29 00:34:44 +00:00
François Revol bb1325a30e [GSoC] [ARM] Patch by Johannes Wischert.
Placeholder private headers for the kernel and libroot.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31820 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-27 16:23:08 +00:00
Stephan Aßmus 5147963dcd headers/private/kernel/util/OpenHashTable.h, Hugo's version, is a bit nicer than
Tracker's OpenHashTable.h which it should eventually replace. We've renamed the
class to BOpenHashTable and changed the interface slightly so that HashTableLink
became superfluous.
Adapted all the code that used it. Since the OpenHashTables no longer clash,
this should fix the GCC4 build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31791 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-27 00:39:12 +00:00
Axel Dörfler f75b8de3fc * Discarded the "parametersSize" parameter from various disk device manager
functions.
* Since we now use UserStringParameter, this fixes the missing null termination
  of the parameter string, and thus bug #4045.
* Removed UserMemoryParameter, as it's no longer in use.
* Adjusted syscalls accordingly.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31779 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-26 17:27:27 +00:00
Axel Dörfler bdee97bc3a * Applied slightly changed patch by Alexander von Gluck.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31708 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-23 08:22:01 +00:00
François Revol ff84453736 [GSoC] [ARM] Patch by Johannes Wischert.
Add dummy args structs.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31700 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-22 18:10:06 +00:00
Ingo Weinhold 0b11ecb18c * Always include the public arch_debugger.h headers. The structures defined
there are prefixed with the respective architecture name. Useful for remote
  debugging a different architecture.
* <x86/arch_debugger.h>: Introduced a structure for the FPU state, so that it
  isn't left to the debugger.
* Removed the _kern_get_thread_cpu_state() syscall. Was originally intended for
  bdb compatiblity, but isn't really needed.
* Kernel x86 arch_get_debug_cpu_state(): The use of fnsave was broken, since
  it reinits the FPU after saving the state. This resulted in weird results
  when debugging functions using the FPU. We now use fxsave, if available.
  Otherwise fnsave + frstor should be used -- not fully implemented yet.
  Same for arch_set_debug_cpu_state().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31682 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-21 22:18:39 +00:00
Axel Dörfler 13aa1795dd * It seems we always have to specify all flags to make it work; removed "flags"
parameter from start_system_profiler().
* Added stack depth, and interval parameters to it, though.
* Profiling the boot process is now possible.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31671 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-21 12:09:15 +00:00
Axel Dörfler c755ecfe96 * Added an emergency key mechanism to the kernel, inspired by Jan Klötzke's
patch from about a year ago (I couldn't use any code of his yet, though,
  but there are a few things left). The emergency keys are triggered by
  pressing Alt-SysReq + key.
* By default, only Alt-SysReq+'d' is used as a means to deliberately enter
  the kernel debugger. F12 belongs to userland again, now :-)
* Debugger add-ons now have another optional method to implement their own
  emergency keys - 'd' for the debugger cannot be overridden, though.
* The mechanism can be turned off via a new kernel setting, so it's not that
  easy anymore to "crash" Haiku if you don't want to.
* Right now, the PS/2 driver, and the pre-input_server in-kernel debugger
  keyboard mini-driver support this, USB not yet.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31660 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-20 20:39:37 +00:00
Ingo Weinhold 7f96148cac Patch by Bryce Groff with changes by myself:
* Added missing name parameter to the partitioning system module child creation
  and child creation validation hooks. Pass the name to them.
* Added BPartitionParameterEditor interface, which is/will be used for editing
  disk system specific parameters.
* Implemented partition parameter editors for BFS initialization and Intel
  partition map child creation.
* Fixed the incorrect supported child partition type iteration in the Intel
  partition map add-on. It does now return actual types.
* Handle the "active" flag parameter in the Intel partitioning system module.
* DriveSetup:
  - Replaced the "Create" submenu by a simple menu item. The type can now by
    chosen in the dialog.
  - Make use of initialization and child creation parameter editors. Some
    non-generic code has been moved to the respective editor implementations
    (BFS, intel partitioning system).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31658 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-20 20:29:16 +00:00
Axel Dörfler 5fbad060b3 * Work-in-progress on a kernel profile service that can be evaluated from
userland afterwards.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31621 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-17 16:21:06 +00:00
Ingo Weinhold a365e1cfbb Patch by Bryce Groff, some changes by myself:
* devfs:
  - devfs_[un]publish_partition(): They no longer get the partition path as
    parameter, but rather the device path and the partition name.
  - Added devfs_rename_partition(), which renames an already published
    partition node.
* KPartition/KDiskDevice:
  - Replaced the fPublished flag by fPublishedName, the name under which the
    partition is published. This simplifies UnpublishDevice() and makes it
    practically infallible.
  - Added GetFileName(), which only returns the partition's file name.
    Simplified GetPath() by using it.
  - When a partition is added/removed the subsequent sibling partitions get a
    new index. Now we also rename their published device nodes (and those of
    their descendents). When something goes wrong we unpublish the concerned
    partition's device to be on the safe side. Would be a shame to accidentally
    format the wrong partition, eh? :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31520 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-11 14:35:04 +00:00
Ingo Weinhold 1cc5e46925 Added offset and size parameters to create_child_partition() and
KPartition::CreateChild(). CreateChild() calls AddChild(), which publishes
the new partition, though at that point offset and size were not set, so that
the published devices would not be usable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31463 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-08 20:26:43 +00:00
Ingo Weinhold fab1c05c05 Split the commpage initialization into two parts. The second part is executed
after all CPUs have been queried for their features. On SMP machines
sysenter/sysexit weren't used before due to the non-boot CPUs appearing not
to have the feature.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31226 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-06-24 13:53:58 +00:00
Ingo Weinhold 6a1f462e72 * arch_debug_get_interrupt_pc() does now optionally return whether the iframe
is a syscall iframe.
* User debugger support: Don't to call BreakpointManager::PrepareToContinue(),
  if the thread returns from a syscall. We don't want to skip breakpoints in
  that case.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31223 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-06-24 11:49:35 +00:00
Ingo Weinhold b0f12d64f4 Added transparent software breakpoint support for user debuggers:
* The bulk of the work -- i.e. juggling the software and hardware breakpoints,
  watchpoints, and memory reads/writes -- is done in the new class
  BreakpointManager.
* For the architectures a few capability macros have to be defined, one
  pointing to the software breakpoint instruction opcode. Done for x86.
* Some more simplifications in the user debugger code, made possible by the
  recently introduced debugger_changed_condition attribute.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31214 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-06-23 21:03:57 +00:00
Ingo Weinhold ba391bcc56 Added team_debug_info::debugger_changed_condition to serialize changes to the
installed team debugger and adjusted the code accordingly. It's not needed yet,
but I intend to add support for software breakpoints and those require a bit of
uninitialization that needs to be synchronized with debugger changes and can't
be done with interrupts disabled.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31194 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-06-23 01:39:51 +00:00
Ingo Weinhold 91393e7810 InterruptsSpinLocking:
* Removed unused inner struct State.
* Added work-around for the extremely annoying "fState my be used
  uninitialized" warning gcc 4 produces. I'm not aware of any solution that
  doesn't generate unnecessary code. :-/


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31193 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-06-23 01:32:46 +00:00
Ingo Weinhold 5ea5f51d84 Changed ConditionVariable from class to struct to make it more C-friendly.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31191 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-06-22 23:49:05 +00:00
Ingo Weinhold 6dcc2a7e00 Made destroy_team_debug_info() static, as it's not used outside the source
file.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31190 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-06-22 23:46:55 +00:00
Axel Dörfler 3609af391d * Renamed _kern_reserve_heap_address_range() to _kern_reserve_address_range(),
and added a _kern_unreserve_address_range() as well.
* The runtime loader now reserves the space needed for all its areas first
  to make sure there is enough space left for all areas of a single image.
* This also fixes the final part of bug #4008.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31115 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-06-19 11:09:21 +00:00
Axel Dörfler 82db8a9e15 * Added an "unmapAddressRange" argument to the file mapping syscall. This is
the first part of making the runtime loader behave itself; it should already
  make Clockwerk run okay with any number of translators (even if not all of
  them will work yet).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31113 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-06-19 08:23:11 +00:00
Ingo Weinhold 568ade58d0 User debugger support:
* Generalized address checks. The debugger can now also read the commpage.
* Added new syscall _kern_get_thread_cpu_state() to get the CPU state of a
  not running thread. Introduced arch_get_thread_debug_cpu_state() for that
  purpose, which is only implemented for x86 ATM (uses the new
  i386_get_thread_user_iframe()).
* Don't allow a debugger to change a thread's "esp" anymore. That's the esp
  register in the kernel. "user_esp" can still be changed.
* Generally set RF (resume flag) in eflags in interrupt handlers, not only
  after a instruction breakpoint debug exception. This should prevent
  breakpoints from being triggered more than once (e.g. when the breakpoint is
  on an instruction that can cause a page fault). I still saw those with bdb
  in VMware, but that might be a VMware bug.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31045 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-06-14 12:14:06 +00:00
Axel Dörfler 477a4ca70e * vfs_boot.cpp now also exports gReadOnlyBootDevice which is true when the
boot device is actually read-only (even if it's using the write overlay).
* Do not create a swap file on a read-only device - this would really be a
  stupid use of the write overlay (just saw this happening on an older
  machine).
* Made swap_file_{add|delete}() take a const char* path - there was no reason
  this was writable, and this also avoids casting away the const when adding
  the default swap file.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30975 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-06-05 15:52:58 +00:00
Ingo Weinhold 360d4974b9 Replaced the temporary storage used in the kernel debug command parser. We now
have a simple dedicated heap for the kernel debugger with stacked allocation
pools (deleting a pool frees all memory allocated in it). The heap should
eventually be used for all commands that need temporary storage too large for
the stack instead of each using its own static buffer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30949 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-06-03 12:28:49 +00:00
Ingo Weinhold eb0262fc4c * Reworked vm_soft_fault() and friends:
- While walking down the cache chain, we keep all upper caches locked.
  - When we have to unlock -- when waiting for a busy page or reading a page in
    -- we unlock completely, including the address space, and restart
    vm_soft_fault().
  - Folded fault_get_page() and fault_find_page() into one.
  This simplifies and improves things considerably:
  - We no longer need dummy pages.
  - We no longer need vm_area::no_cache_change.
  - #2710 is fixed, since we no longer hold the address space lock while
    waiting.
* vm_soft_fault(): When we have found our page, we first check whether a page
  is already mapped at the address. If it is already our page, we just change
  its protection. If not, we unmap it first. Fixes race conditions when multiple
  threads fault at the same address at the same time.
* fault_get_page(): When copying a read-only page from a lower cache, no longer
  mark it active, since at least for the fault area it is shadowed from then on.
* vm_set_area_protection(): Fixed potential overflow for in the
  vm_translation_map::protect() call.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30911 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-05-29 12:55:25 +00:00
Ingo Weinhold 7515c32c1f Not sure, if this was only a gcc 4.3.3 bug or if I misunderstand something, but
gcc could apparently assume that the register assigned to the one in the
clobber list would keep its value (as can be observed when disassembling
add_debugger_command_etc()).
Using a dummy output register works around the problem and also avoids the
unnecessary initialization of the register.

Comments explaining the mystery welcome.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30909 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-05-29 01:17:53 +00:00
Ingo Weinhold 9bf61a0ecc * Added GNU style ELF symbol versioning support in the kernel, too.
* Fixed memory leak in insert_preloaded_image() in error case.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30820 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-05-21 15:08:42 +00:00
Ingo Weinhold 6a1e04b121 Symbol resolution functions in the kernel: Removed the unused parameter
allowing optional prepending of a string to the symbol names.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30750 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-05-13 15:25:27 +00:00
Axel Dörfler 2d8073a9dc * Added a TODO about a problematic use of vm_page_allocate_page() in combination
with vm_cache_acquire_locked_page_cache().
* Added new function vm_page_num_unused_pages() which returns the pages that are
  actually completely free and unused.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30514 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-04-30 15:46:55 +00:00
Stephan Aßmus eb2bd0e8e3 axeld:
* Implemented a way to do asynchronous pre-fetching when mapping files.
* There are slight code duplications in some places that could benefit
  from cleaning up, but nothing too bad.
* Implementing smarter ways to trigger prefetching and more analysis of
  the situations in the kernel would be nice. Currently up to 10 MB
  of every mapped file are pre-fetched without further analysis.
* The speed improvement is nice for certain operations. On our test
  system (real hardware), Firefox took 9 seconds from being launched
  to display a window. Now it takes 5 seconds. Both measurements
  right after booting. The same system took 35 seconds from launching
  Haiku in the GRUB menu to displaying the Tracker desktop background
  image. Now it takes 27 seconds.
* We didn't have the chance to check out the effects of this on the
  CD boot, but potentially, they could speed it up a lot.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30465 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-04-27 18:16:58 +00:00
Ingo Weinhold 57e7daa5a4 Added missing include.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30404 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-04-25 18:34:24 +00:00
Ingo Weinhold a7ccfc910c Added WaitObjectListener destructor. Hopefully fixes the gcc 2 build.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30346 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-04-23 14:53:18 +00:00
Ingo Weinhold 227fe7d34a * Scheduler/wait object listener:
- Moved scheduler listening interface to <listeners.h> and added more
    convenient to use templatized notification functions.
  - Added a listener mechanism for the wait objects (semaphores, condition
    variables, mutex, rw_lock).
* system profiler:
  - Hopefully fixed locking issues related to notifying the profiler thread
    for good. We still had an inconsistent locking order, since the scheduler
    notification callbacks are invoked with the thread lock held and have to
    acquire the object lock then, while the other callbacks acquired the object
    lock first and as a side effect of ConditionVariable::NotifyOne() acquired
    the thread lock. Now we make sure the object lock is the innermost lock.
  - Track the number of dropped events due to a full buffer.
    _user_system_profiler_next_buffer() returns this count now.
  - When scheduling profiling events are requested also listen to wait objects
    and generate the respective profiling events. We send those events lazily
    and cache the infos to avoid resending an event for the same wait object.
  - When starting profiling we do now generate "thread scheduled" events for
    the already running threads.
  - _user_system_profiler_start(): Check whether the parameters pointer is a
    userland address at all.
  - The system_profiler_team_added event does now also contain the team's name.
* Added a sem_get_name_unsafe() returning a semaphore's name. It is "unsafe",
  since the caller has to ensure that the semaphore exists and continues to
  exist as long as the returned name is used.
* Adjusted the "profile" and "scheduling_recorder" according to the system
  profiling changes. The latter prints the number of dropped events, now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30345 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-04-23 13:47:52 +00:00
Ingo Weinhold 8b3b05cbf9 Synchronize the TSCs of all CPUs early in the boot process, so system_time()
will return consistent values. This helps with debug measurements for the time
being. Obviously we'll have to think of something different when we support
speed-stepping on models with frequency-dependent TSCs.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30287 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-04-21 00:38:11 +00:00
Ingo Weinhold 65d2b8a8e9 * Introduces VMCache::CanWritePage() returning whether the given cache can
theoretically write the given page.
* page writer: Fixed the incorrect check whether a temporary page can be
  written by using the new CanWritePage().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30281 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-04-20 15:19:41 +00:00
Ingo Weinhold 5b2f0f33f9 * Changed the interface of _kern_system_profiler_start(). The parameters are
passed in a structure now, so it is easier to extend it and ignore unused
  parameters.
* One can now select which system profiling events one is interested in.
* Added scheduling events to the system profiling interface. Those are pretty
  much the ones recorded when scheduler tracing is enabled. Still missing are
  the "wait object" events that allow to interpret what a thread is waiting
  for.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30243 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-04-18 17:35:28 +00:00
Ingo Weinhold 79257a4ad6 Added a listener mechanism to the scheduler (ATM only for scheduler_simple).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30242 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-04-18 17:24:58 +00:00
Ingo Weinhold e2ae69da52 The kernel side of a new system-wide sampling-based profiling mechanism.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30127 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-04-11 22:20:51 +00:00
Ingo Weinhold efd536ff89 * Cleared up a misconception in the notification mechanism. We already had
methods that used an "event mask" field. There was no need to introduce
  a "flags" field for the same purpose.
* Renamed protected DefaultNotificationService methods (removed "_" prefix).
* Adjusted the code providing a notification service accordingly.
* Changed the event message several notification services generated by renaming
  the "opcode" field to "event".
* Implemented the TEAM_ADDED event and also added a TEAM_EXEC event.
* Added notifications for threads and images.
* Added visitor-like iteration functions for teams, threads, and images.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30126 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-04-11 21:45:25 +00:00
Ingo Weinhold 60bfde6e0f Added data accessors for B_POINTER_TYPE.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30124 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-04-11 21:29:22 +00:00
Ingo Weinhold b36c8ba26a Added elf_get_kernel_image() returning the image for the kernel.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30036 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-04-08 16:47:45 +00:00
Axel Dörfler 8263f82d90 * Missed that when cleaning up the style.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29980 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-04-06 21:13:06 +00:00
Axel Dörfler fd0803f300 * Added RemoveTail() method.
* Renamed DoublyLinkedList::Size() to Count(), since it actually counts the
  items (ie. O(n)).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29979 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-04-06 21:06:19 +00:00
Oliver Tappe f9ae64e9a5 zooey + bonefish:
* optimized unmapping of a single page that was rather inefficient
  for large areas

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29978 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-04-06 20:46:18 +00:00
Oliver Tappe 31ffd6533a zooey + bonefish:
* made usable from C

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29977 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-04-06 20:42:05 +00:00
Ingo Weinhold 328029e178 Patch by Alexander von Gluck (kallisti5) to get the PPC build going again
(mostly at least). Also disables -Werror for the binutils, but those should
be fixed eventually.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29804 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-03-30 15:00:10 +00:00
Rene Gollent dc707c28aa Small cleanup, no functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29784 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-03-29 16:53:38 +00:00
Ingo Weinhold 002c9410ed Missing "struct thread" declaration, breaking the PPC build.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29780 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-03-29 14:43:36 +00:00
Rene Gollent 0296b82ae6 Add several extra scheduler hook functions to allow the scheduler(s) to maintain private housekeeping data on the thread structs. These hooks are called on thread creation/destruction and when prepping a thread for use. Review welcome.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29721 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-03-26 00:58:20 +00:00
Axel Dörfler 3f78b216ad * Implemented a basic notification mechanism. Right now, only media changes and
device additions/removals can be monitored.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29582 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-03-18 08:55:49 +00:00
Axel Dörfler 51755cf832 * Added DefaultNotificationService and DefaultUserNotificationService
implementations that can be used by subsystems that want to have a pretty
  standard service. Only the latter is really complete, though.
* The notification manager is now available earlier in the boot process.
* Added notifications to teams/ports (only add/remove).
* The network notification implementation is now using the
  DefaultUserNotificationService.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29543 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-03-15 10:21:56 +00:00
Michael Lotz 5b9d5a2ec9 * Add has_debugger_command() so whether or not a debugger command is available
can be checked.
* Make the usb_keyboard module check the presence of the needed debugger
  commands to avoid the error messages in case of them being unavailable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29472 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-03-11 12:17:23 +00:00
Ingo Weinhold b538ceb816 Added dup_foreign_fd() to duplicate a FD from another team.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29468 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-03-11 00:57:17 +00:00
Ingo Weinhold 2d4fb82c0f Added TableSize(), CountElements(), and Clear() methods.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29428 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-03-07 21:19:15 +00:00
Ingo Weinhold a7edf1f7c0 Moved RECURSIVE_LOCK_HOLDER() macro to the header and fixed it.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29407 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-03-05 23:15:15 +00:00
Ingo Weinhold 5ecc4b3775 * Introduced ref-counting for the I/O contexts.
* The I/O context related vfs_*() functions have io_context* instead of void*
  parameters/return values, now.
* vfs_new_io_context(): Lock the parent I/O context before getting its table
  size. Otherwise the table size could change until we do.
* vfs_resize_fd_table(): Fixed use of MutexLocker. We created only a temporary
  object, not one with function scope.
* Renamed load_image_etc() to load_image_internal() and added a parameter for
  specifying the parent team of the one to create.
* Introduced a kernel private load_image_etc() with a few more arguments than
  load_image().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29375 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-03-02 00:26:22 +00:00
François Revol 595d8a3b9c Fix for gcc4 build. Thx Monni.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29340 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-02-27 22:44:05 +00:00
Ingo Weinhold 42ef52132a Made usable from userland.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29335 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-02-27 16:11:57 +00:00
Ingo Weinhold e1975d3353 * When a team debugger is installed automatically, the thread causing that is
stored now.
* Extended the debugger message for B_DEBUGGER_MESSAGE_HANDED_OVER by the
  causing thread.
* Also send B_DEBUGGER_MESSAGE_HANDED_OVER to the debugger to which the team
  was handed over. The message will be the very first one the debugger gets
  from the team in question.
* Some harmless refactoring (added thread_hit_serious_debug_event()).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29302 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-02-23 22:59:45 +00:00
Michael Lotz 6eba063647 * Added simplified possibility to schedule UHCI transfers from within KDL.
* Added debugger commands to resolve usb_ids to pipes.
* Adjusted the physical memory allocator to be usable in a slimmed down mode
  when running inside the kernel debugger.
* Implemented USB keyboard support for KDL through a kernel debugger add-on.
* Added kgetc() and made use of it where previously individual methods were used
  to ensure that reading characters always goes through the kernel debugger
  add-ons and the other methods.

This has some preconditions to meet though:
1) The keyboard must be in the boot protocol (currently the case but needs to
   be revisited once we have a full usb_hid).
2) The keyboard must be attached to a UHCI root port (i.e. not use EHCI or OHCI,
   also not through hubs unless those are USB 1.1).
3) the usb_hid driver has to be opened for this to work. This means that for the
   time between initializing USB and when usb_hid is opened by the input_server
   there is no keyboard support.

Also note that this has no way of detecting hot-plug, meaning that you can't
re-attach your USB keyboard from the hub to the root port once in KDL.

On the bright side of things, since this is a non-destructive mechanism it is
possible to enter and leave KDL without loosing the USB state.

Tested OK in QEMU, not tested on real hardware yet, will see in a few minutes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29291 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-02-22 20:46:27 +00:00
Michael Lotz 3684e40bb8 * Introduce a (private) flag B_NO_HANDLED_INFO for install_io_interrupt_handler.
It causes the interrupt handler to be inserted at the very end of the list
  instead of at the top. It is intended to be used as a workaround when a
  interrupt handler cannot know if it actually handled the interrupt. This
  should never be used by native drivers. Also if we know that the result is
  not valid because of this flag we won't disable the vector in case we count
  many unhandled interrupts as those numbers are then unreliable.
* Moved B_NO_LOCK_VECTOR to be a private flag as well.
* Made the interrupt handler list a simple manually maintaned singly linked list
  instead of the doubly linked one used with insque and remque as it greatly
  simplifies things for such an easy use case and is more compact.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29241 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-02-17 21:41:51 +00:00
Michael Lotz c33667d400 Fixing warnings under GCC4 in preparation to enable -Werror there as well:
* Replaced the use of offsetof() for structs that aren't PODs. Add a
  offset_of_member() macro to util/khash.h because that's what it's used for
  in our cases.
* Change the signature of add_debugger_command()/remove_debugger_command() on
  GCC > 2 to avoid the depricated conversion from string constants to char *.
* Adding some "suggested" parenthesis. I know that not everyone likes that, but
  it pointed out at least one bug that is fixed here as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29113 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-02-01 20:48:02 +00:00
Axel Dörfler 2c1e463c7e * Removed B_{MIN|MAX}_PRIORITY from OS.h - they were never really intended
as public defines. They are now called THREAD_{MIN|MAX}_SET_PRIORITY to
  better reflect what they are for. Minimum priority is now 1, ie. you no
  longer can set another thread to the idle priority. This fixes part of
  ticket #2959.
* set_thread_priority() will no longer allow to change the priority of the
  idle thread to something else. This fixes the rest of ticket #2959.
* Automatic whitespace cleanup in OS.h.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28521 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-11-05 18:11:58 +00:00
Ingo Weinhold 56eb43e3ca * Made kernel_cpp.h usable in the runtime loader.
* Added new(mynothrow) operators which avoid clashes when also linking
  against libgcc.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28474 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-11-03 13:15:12 +00:00
François Revol 9da2356857 Work in progress to pass the image extents to the kernel,
- code is disabled yet as the bootloader doesn't have add_boot_item.. will need to pass via kernel args
- add a GetFileMap() method to the vfs, and implement it in FAT code.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28445 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-11-01 20:39:14 +00:00