Commit Graph

1981 Commits

Author SHA1 Message Date
Rene Gollent 7040b50df5 Add support for thread rename and priority change notifications to the
debugger API/message set.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39846 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-12-14 05:08:47 +00:00
Ingo Weinhold 07655104d5 Eliminated _acquire_spinlock(). Since the macro is defined after
acquire_spinlock_inline(), there's actually no undesired recursion.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39647 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-11-26 13:55:20 +00:00
Ingo Weinhold c07db2ec3f * elf_find_symbol(): Skip undefined symbols and symbols with the wrong binding.
* Implemented missing handling of symbolically linked images and of weak
  symbols.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39646 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-11-26 13:32:24 +00:00
Ingo Weinhold 56d734a1aa Added new private API to get more information on a team:
* Userland interface: get_extended_team_info().
* Syscall: _kern_get_extended_team_info.

Only partially implemented yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39453 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-11-16 19:42:08 +00:00
Ingo Weinhold 5609b854b5 Added a Remove() version to which the previous element needs to be passed as
well. This is rather ugly, but it was the quickest way to provide O(1) element
removal. This class could really use some love.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39296 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-11-04 14:58:10 +00:00
Ithamar R. Adema c917cd6261 * ARM: Major VM work
- This is mostly a copy of the x86 32bit paging method and infrastructure, this was copied for two reasons:
		1) It is the most complete VM arch
		2) The first ARM PAE patches have landed on alkml, so we will have to deal with it in the future as well,
		   and this infrastructure has proven to be ready ;)
	- No protection features, or dirty/accessed tracking yet
	- Lots of #if 0

	but....

	It boots all the way up to init_modules() now, and then dies because of a lack of (ARM) ELF relocation implementation!

	Since at this point the VM can be fully initialised, I'm going to focus on CPU exceptions next, so we can get KDL to trigger
	when it happens, and I can actually debug from there ;)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39206 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-10-30 14:10:30 +00:00
Ithamar R. Adema 107ce9b0fb * ARM: Remove fields that were no longer used since r39168...
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39205 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-10-30 13:57:32 +00:00
Ingo Weinhold 13b81a3b8e * Added new thread flag THREAD_FLAGS_SINGLE_STEP, which is set to indicate that
userland single-stepping is enabled for the thread.
* x86_exit_user_debug_at_kernel_entry(): Always store DR6 and DR7 in the CPU
  structure, not only when breakpoints are installed.
* x86_handle_debug_exception(): When encountering a syscall single-step, also
  set the THREAD_FLAGS_DEBUG_THREAD thread flag. Otherwise the
  B_THREAD_DEBUG_STOP would be ignored.
* x86 interrupt handling, DISABLE_BREAKPOINTS():
  - Renamed to STOP_USER_DEBUGGING().
  - Now it also call x86_exit_user_debug_at_kernel_entry() when
    THREAD_FLAGS_SINGLE_STEP is set, so that the debug registers are saved.

Fixes #6751.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39201 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-10-30 11:31:01 +00:00
François Revol c489b073c8 Partial build fix. Still a lot to do to catch up with Ingo...
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39189 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-10-30 01:33:50 +00:00
Ithamar R. Adema d38153721e * Add page directory/table helper macros.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39137 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-10-25 11:16:21 +00:00
Ithamar R. Adema 2609a6bc98 * Fix header guard.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39133 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-10-24 22:06:22 +00:00
François Revol c8afe2ca9b Fix header guard which prevented from including text_console.h along with this one.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39075 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-10-23 19:08:52 +00:00
Fredrik Holmqvist f55ffb1a8e Completed structures for MADT APIC structures. I may now have a Frankenheimer.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39073 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-10-23 15:49:17 +00:00
Jérôme Duval 01929b0c94 added a mapping for 0x83 to BTRFS
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39069 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-10-23 15:19:58 +00:00
Fredrik Holmqvist 868d2a2ed5 Compile first, commit after. Not the other way around.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39061 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-10-23 09:49:55 +00:00
Fredrik Holmqvist a808dd7283 Adding more structures for MADT APIC structures. Correct some missed documentation.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39060 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-10-23 09:48:17 +00:00
Fredrik Holmqvist d7a03e967e Started adding structures for MADT APIC structures.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39059 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-10-23 09:01:24 +00:00
Fredrik Holmqvist 228b810454 Add the different APIC type ids for MADT APIC structures.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39057 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-10-23 07:44:39 +00:00
Ithamar R. Adema 150820bc87 * Remove PXA270 code from Freerunner header file
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39048 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-10-22 17:31:04 +00:00
Philippe Houdoin 5f86ad125d Relax the copyright...
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38948 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-10-11 13:39:37 +00:00
Philippe Houdoin 89fa2a8573 Move the boot images conditional selection in one place, to remove
possible mismatch images info between loader and kernel.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38947 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-10-11 12:54:21 +00:00
Philippe Houdoin 3bd99634d1 Make the development boot splash more discret, relaying on the usual
quite hidden bug theme.
This also reduce its RLE compression size, which should fix #6710.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38946 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-10-11 10:47:06 +00:00
François Revol 91d95c16eb Clone atari platform args headers. This gets the Amiga loader to link.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38937 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-10-10 18:16:16 +00:00
Philippe Houdoin 64141b1b74 Enable development splash logo for "official" --distro_compatibility.
The official release one stay the well-known one, just renamed to show it's trademarked images.
Fixed #6183.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38891 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-10-05 10:31:13 +00:00
Fredrik Holmqvist 01f964efeb Introduce a gSystemShutdown flag to be able to check if system is shutting down. ACPI Embedded Controller now uses polling when it is set to true.
This might help with ACPI shutdown issues, if not this change can be reverted. Not verified as it works on all my machines even without this.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38585 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-09-08 19:19:49 +00:00
Andreas Färber 5b086e27e8 boot_net: Add iSCSI initiator support
Add support for both discovery and regular iSCSI sessions. Command and status
sequence numbers do differentiate between session and connection but only
one connection per session is currently supported.

Code is Big Endian for now, so compile it for ppc only.

Based on RFC 3720 ff. Tested against OpenSolaris 2009.06.

Resolves most of ticket #5319.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38536 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-09-05 22:30:41 +00:00
Andreas Färber 040b33980c boot_net: Prepare socket-specific TCP window size
Pass the desired window size from the socket to the service.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38530 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-09-04 22:36:35 +00:00
Andreas Färber b7e825d6e7 boot_net: Add TCP support
Modelled after UDP, add limited TCP support to the boot net stack. The socket
works by queuing received packets as well as sent packets that have not yet
been ACK'ed. Some known issues are documented, especially there's only limited
congestion control. I.e., we send immediately and in unlimited quantity, thus
its use should be restricted to local networks, and due to a fixed window size
there is potential for our socket being overrun with data packets before they
are read. Some corner cases like wrapping sequence numbers may cause a timeout.

The TCP implementation is based on Andrew S. Tanenbaum's "Computer Networks",
4th ed., as well as lecture notes from Prof. W. Effelsberg, the relevant RFCs
and Wikipedia. The pseudo-random number Galois LFSR used for the sequence
number was suggested by Endre Varga.

Since the code is unlikely to get much smaller, better merge it now so that
subsequent changes get easier to review. No platform actively uses TCP sockets
yet, and the receiving code has been reviewed for endianness issues and should
terminate okay after verifying the checksum if no sockets are open.
Based on a version tested with custom code (#5240) as well as with iSCSI.
Compile-tested boot_loader_openfirmware, pxehaiku-loader with gcc4 and
haiku_loader with gcc2. Closes ticket #5240.

Changes from #5240 proposed patch:
* Various bug fixes related to queuing, some memory leaks fixed.
* Never bump the sequence number when dequeuing a packet. It's done afterwards.
* Don't bump the sequence number again when resending the queue or ACK'ing.
* Aggressively ACK while waiting for packets.
* Don't queue sent ACK-only packets.
* More trace output, esp. for queue inspection.
* Adapted use of TCP header flags to r38434.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38472 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-31 01:00:06 +00:00
Andreas Färber 30743318f1 boot net: Style fixes
Fix style issue, pointed out by Axel.

No functional changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38456 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-30 18:50:14 +00:00
Andreas Färber df66656fec boot net: Preparations for TCP
Add protocol number and struct for TCP header.

First minuscule part of ticket #5240.
Checked that pxehaiku_loader still compiles, too.

Changes from proposed patch:
* Simplify struct by merging flags into one 8-bit field.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38434 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-29 22:12:17 +00:00
Andreas Färber b96cb61620 boot net: Style fixes
No functional changes yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38431 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-29 21:34:16 +00:00
Oliver Tappe dbe1e23aa8 Optimised passing around of timezone a bit
* _kern_[sg]et_timezone() now accepts/passes out the timezone name, too
* adjust Time preflet and clockconfig to pass the timezone name into the kernel
  when calling _kern_set_timezone()
* ajust implementation of tzset() to fetch the timezone name from the kernel
  via _kern_get_timezone() instead of reading 'libroot_timezone_info'
* the Time preflet no longer writes 'libroot_timezone_info'


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38164 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-16 22:01:28 +00:00
Oliver Tappe 6bb7a098b7 * added missing 'void' to make the get_timezone_offset() declaration a proper
prototype and not just a forward


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37910 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-04 21:57:44 +00:00
Oliver Tappe e0ea55e0a0 * added get_timezone_offset() to kernel, which returns the offset in seconds
* made FAT add-on use get_timezone_offset(), this time correctly adjusted for
  the difference in units (minutes/seconds)
This makes the times in our FAT-fs agree with Linux again, at least :-)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37905 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-04 17:11:47 +00:00
Oliver Tappe 7e965f506d More consolidation of timezone code:
* dropped DaylightSavingTime from real_time_clock code in kernel, it was
  never really being used for what it meant (and just being referred to by
  gettimeofday(), which put a different meaning to it
* adjusted the syscalls get_timezone() & set_timezone() as well as their callers 
  accordingly
* got rid of get_rtc_info() and rtc_info struct in kernel, as it was only
  being referred to by the FAT add-on and that one (like gettimeofday()) put a
  different meaning to tz_minuteswest. Added a comment to FAT's util.c
  showing a possible solution, should the hardcoded GMT timezone pose a problem.
* fixed declaration of gettimeofday() to match POSIX base specs, issue 7
* changed implementation of gettimeofday() to not bother trying to fill struct
  timezone - it was using wrong values before, anyway.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37888 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-03 23:02:57 +00:00
Oliver Tappe 96ac47e312 Made some progress with consolidation of timezone-related code:
* renamed syscalls _kern_[gs]et_tzfilename 
  to _kern_[gs]et_real_time_clock_is_gmt, as the filename part is no longer
  relevant (and the two corresponding parameters were removed)
* C++-ified and reworked clockconfig to use the info from 'Time settings' 
  to setup the timezone info during boot
* removed invocation of _kern_get_tzfilename() from tzset(), as the syscall
  no longer exists and tzset() is currently broken anyway
* adjusted the Time preflet to use the renamed syscall when getting/setting 
  the RTC info


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37881 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-03 17:47:26 +00:00
Matt Madia 9072a31477 Added a boot splash header file that contains only the boot icons. Later,
video_splash.cpp and boot_splash.cpp will be updated to utilize it.

Relates to #6183. See #6255 for issues on using 'splash_logo-development.png'
with generate_boot_screen.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37739 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-07-25 18:44:52 +00:00
Ingo Weinhold 4e08fb8589 Added rw_lock_read_lock_with_timeout().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37680 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-07-22 11:10:48 +00:00
Fredrik Holmqvist a636d1e365 Patch by kaliber to fix some compiling errors with clang. Removed the #include <iostream> part, but otherwise not modified.
See http://clang.llvm.org/compatibility.html#c++ why it is needed. Note that HashMap.h Key and Value are typenames as well.
Afaict this is correctly done, builds and runs on gcc4. This fixes #5892.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37550 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-07-17 10:33:24 +00:00
Ingo Weinhold b944766870 * Moved the vm_page initialization from vm_page.cpp:vm_page_init() to the new
vm_page::Init().
* Made vm_page::wired_count private and added accessor methods.
* Added VMCache::fWiredPagesCount (the number of wired pages the cache
  contains) and accessor methods.
* Made more use of vm_page::IsMapped().
* vm_copy_on_write_area(): Added vm_page_reservation* parameter that can be
  used to request a special handling for wired pages. If given the wired pages
  are replaced by copies and the original pages are moved to the upper cache.
* vm_copy_area():
  - We don't need to do any wired ranges handling, if the source area is a
    B_SHARED_AREA, since we don't touch the area's mappings in this case.
  - We no longer wait for wired ranges of the concerned areas to disappear.
    Instead we use the new vm_copy_on_write_area() feature and just let it
    copy the wired pages. This fixes #6288, an issue introduced with the use
    of user mutexes in libroot: When executing multiple concurrent fork()s all
    but the first one would wait on the fork mutex, which (being a user mutex)
    would wire a page that the vm_copy_area() of the first fork() would wait
    for.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37460 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-07-10 15:08:13 +00:00
François Revol dae84707ac Patch by "notzed" (Ticket #5380): Add support for setting video mode for OMAP3.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37321 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-30 17:39:36 +00:00
François Revol 6c6d79f7fa Add some defines for memory ranges. Missed in r37319.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37320 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-30 17:25:08 +00:00
François Revol 9020ce87e6 Patch by "notzed" (ticket #5368) (modified): Add bootloader support for BeagleBoard.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37319 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-30 17:24:11 +00:00
François Revol 2e749db8bf Debug console on FreeRunner is on UART3, though you need a debug board.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37306 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-30 00:05:30 +00:00
Andreas Färber d46ce4d62a kernel_ppc: Save caller's stack pointer in arch_debug_save_registers
Suggested by Ingo in ticket #6139. Code is adapted from x86.
Note that on ppc64 GPR1 needs to be 64-bit, thus the choice of addr_t.

Resolves part of ticket #6160.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37281 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-27 20:16:59 +00:00
Andreas Färber 04ec719a70 Convert line endings to LF
In r33670 the svn:eol-style property was dropped, which took care of
locally converting the line endings to the user's native style.
While most files use Unix-style LF line endings, some files have
Windows-style CR LF line endings.

Assure that the following r37262 directories use Unix-style line endings:

src/system/boot/
src/system/boot/arch/
src/system/boot/arch/ppc/
src/system/boot/loader/
src/system/boot/loader/net/
src/system/boot/platform/
src/system/boot/platform/openfirmware/
src/system/boot/platform/openfirmware/arch/
src/system/boot/platform/openfirmware/arch/ppc/
src/system/kernel/
src/system/kernel/arch/
src/system/kernel/arch/ppc/
src/system/kernel/platform/
src/system/kernel/platform/openfirmware/
headers/private/kernel/
headers/private/kernel/arch/
headers/private/kernel/arch/ppc/
headers/private/kernel/platform/
headers/private/kernel/platform/openfirmware/
headers/private/kernel/boot/
headers/private/kernel/boot/net/
headers/private/kernel/boot/platform/
headers/private/kernel/boot/platform/openfirmware/

This avoids patches containing irrelevant lines unintentionally converted.

No functional changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37265 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-26 17:38:03 +00:00
Fredrik Holmqvist e5dca54f1a r37259 fails to compile on one of my systems without this header. Checking out fresh tree and reconfiguring didn't work so don't really know why.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37263 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-26 17:24:11 +00:00
Ingo Weinhold 45bd7bb3db Removed unnecessary inclusions of <boot/kernel_args.h> in private kernel
headers and respectively added includes in source files.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37259 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-25 22:16:10 +00:00
Ingo Weinhold b46540452a Added vm_page_max_address() which returns the greatest address of accessible
physical memory.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37230 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-23 13:52:32 +00:00
Ingo Weinhold ff9151d11f Added ignore_physical_memory_ranges_beyond_4gb() which removes the memory
beyond 4 GB from the physical memory ranges.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37224 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-06-23 11:10:01 +00:00
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