Commit Graph

3799 Commits

Author SHA1 Message Date
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
5a0b30dbda Don't cancel the alarm on exec*(). POSIX alarm() requires that. The BeBook
doesn't mention the expected set_alarm() behavior. Tests under BeOS R5 Bone
crash the system in either case, though, so I guess we're free to go with the
expected POSIX behavior.
This make detection of hanging tests in the Open POSIX Test Suite work.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36046 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-06 17:06:08 +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
21ff565f76 AddressSpaceWriteLocker: Added VMAddressSpace* constructor and SetTo()
versions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36029 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-03 16:11:47 +00:00
Ingo Weinhold
345730da43 Fixed gcc 2 build.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35981 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-27 20:16:10 +00:00
Ingo Weinhold
25bca18888 Moved setting the debug syslog default to main(). Previously that was done
only when the boot loader menu was entered.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35977 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-27 18:15:17 +00:00
Ingo Weinhold
c81e68b2b2 "syslog" debugger command: By default it now ignores the output added to the
syslog in the current KDL session. Added option "-k" for the former behavior.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35976 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-27 18:13:11 +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
a959bc5b23 _user_wait_for_objects(): Don't copy the infos back to userland when an error
occurred. This fixes the automatic syscall restart case (would wait forever)
and aligns the behavior with poll().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35948 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-25 15:57:38 +00:00
Ingo Weinhold
a369198603 kernel_debugger_loop(): We need to use a dedicated jmp_buf for the call of
arch_debug_stack_trace() through debug_call_with_fault_handler(), since the
one in the CPU structure can only be used for debug_{strl,mem}cpy(), which do
not potentially have nested debug_call_with_fault_handler() calls.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35920 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-19 21:30:27 +00:00
Ingo Weinhold
4f339c2ce1 preload_image(): Removed erroneous rld_unlock() in error case. Fixes #5599.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35919 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-19 19:21:41 +00:00
Ingo Weinhold
c561bf792b block_cache::NewBlock(): Allocate cached_block::current_data only when the
block was freshly allocated. A block returned by _GetUnusedBlock() already
has current_data and we would leak it before.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35918 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-19 19:07:18 +00:00
Ingo Weinhold
59a4ec37b5 Changed the names of the block allocator object caches to avoid confusion
with the ones of the block cache.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35917 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-19 18:27:28 +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
d80af65fd8 The "page" and the "cache" kernel debugger commands set a few temporary
variables, now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35903 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-18 16:18:16 +00:00
Ingo Weinhold
2d2b6b1f1a * Unconditionally print a stack trace when we entered KDL via panic().
* Print the initial stack trace safely, i.e. in a setjmp() + fault handler
  environment.
* Disable pagination while executing the executing the panic() commands. This
  way even when it is not possible to use the keyboard we get the full output.
* Added "panic_commands" kernel debugger command, to execute the panic()
  commands again (with pagination enabled).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35902 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-18 16:17:15 +00:00
Ingo Weinhold
976e52595e Added blue_screen_paging_enabled() and blue_screen_set_paging() to get/set
pagination mode.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35901 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-18 16:11:29 +00:00
Stefano Ceccherini
43e738bd36 Style fixes
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35897 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-18 06:31:01 +00:00
Ingo Weinhold
64c15cfc27 * sCurrentKernelDebuggerMessageArgs is no longer used directly. Whenever it
is passed to some v*printf(), we clone it first. This way we can use it
  repeatedly. It worked only on certain architectures correctly before.
* Changed the panic() semantics a bit: When the format contains the
  (hopefully unusual enough) string "@!" only the part before it is
  considered to belong to the panic message. The part after it is interpreted
  as a command line to be executed directly after entering KDL. This way it
  is possible to provide helpful command invocations only developers somewhat
  familiar with the subsystem might come up with. E.g.:
    panic("dec_vnode_ref_count: called on busy vnode %p"
      "@! vnode -p %p; mount _mount", vnode, vnode);


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35896 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-18 00:47:43 +00:00
Ingo Weinhold
6365627b33 * Added support for giving multiple kernel debugger commands in a single
line, separated by ";".
* Fixed incorrect parsing when "|" was not separated by a space from the
  previous argument.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35895 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-17 22:56:07 +00:00
Stefano Ceccherini
33e11f7c0f Squashed todo: only compute the numEntries once, and made it static.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35889 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-17 12:19:34 +00:00
Ingo Weinhold
38c7ed7c47 Added kernel debug config option KDEBUG_ENABLE_DEBUG_SYSLOG which determines
the default setting for the "debug syslog" feature (can still be overridden
in the boot loader). Per default enabled for kdebug level >= 1.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35884 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-16 19:39:22 +00:00
Ingo Weinhold
3fded33493 * Write kernel debugger output to the syslog as well. This should make life
for people who cannot capture serial output easier.
* The syslog sender thread waits with timeout now, so output added to the
  syslog buffer without explicit notification is still written after a few
  seconds at the latest.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35883 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-16 19:36:54 +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
d1367a37cc Implemented BIOSDrive::WriteAt(). Currently it supports only LBA addressing
and requires position and size to be block-aligned.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35881 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-16 17:10:00 +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
f427f6af3f Added some kernel tracing for sigsuspend().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35834 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-13 12:31:01 +00:00
Ingo Weinhold
6daecfb154 Ignore physical memory ranges that are smaller than 64 KB. Those don't
contribute significantly to the usable memory, but possibly make the MTRR
setup impossible. Might improve #5550.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35825 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-12 16:59:26 +00:00
Ingo Weinhold
6b110c63fd Postpone clearing the debug syslog buffer signature to the time when going
to start the kernel with the option disabled.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35823 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-12 12:57:35 +00:00
Ingo Weinhold
98248b1612 Let the compiler decide whether to inline or not.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35821 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-12 11:25:30 +00:00
Matt Madia
4a27232637 Fixes build for PXE NetBoot. Uncertain if additional changes are needed.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35818 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-11 20:15:39 +00:00
Ingo Weinhold
8d25a30c3f Changed the location for the debug syslog buffer from 16 MB to 63 MB. On my
machine the previous location was overwritten, probably by GRUB.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35817 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-11 18:15:43 +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
90bf6bef34 Added mmu_allocate_physical(), which allocates a specified physical memory
range.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35815 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-11 17:42:00 +00:00
Ingo Weinhold
bb7711cd5a Updated boot loader copyright year.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35814 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-11 17:13:12 +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
dd5f340aea A simple pager implemented on top of the generic text console interface.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35812 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-11 17:09:11 +00:00
Ingo Weinhold
5d1f3d53e2 get_next_physical_address(): Directly update the
gKernelArgs.physical_allocated_range array. This way it is always up to date
and we don't need to fix it in mmu_init_for_kernel().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35802 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-10 18:38:57 +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
Axel Dörfler
47f23fb5c1 * If get_cached_block() failed reading a block, it would leave a deleted object
in the unused list if it got the block via block_cache::_GetUnusedBlock().
* block_cache::_GetUnusedBlock() leaked the compare data block if the
  BLOCK_CACHE_DEBUG_CHANGED feature had been enabled.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35799 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-10 10:57:37 +00:00
Ingo Weinhold
a915c50a60 panic() when running out of MTRRs. I know I'm gonna regret this...
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35755 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-04 09:49:53 +00:00
Ingo Weinhold
affb47166b add_mtrrs_for_range(): Fixed computation of the register ranges. Per power of
2 size we might need to use two registers (for the start and the end of the
range).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35753 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-04 09:43:04 +00:00
Ingo Weinhold
2a196c6349 exchange_with_empty() did not set the freeMagazine return value to NULL when
the maximum magazine count wasn't reached yet. With object_depot_store() not
resetting its local variable, a magazine could thus be emptied and freed
twice. Fixes #5489 and #5497.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35752 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-04 01:55:37 +00:00
Ingo Weinhold
1aed263998 TracingMetaData::_InitPreviousTracingData():
* More output.
* Actually increment errorCount when encountering an error. The loop
  condition would never be false this way.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35750 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-03 23:23:09 +00:00
Ingo Weinhold
7263efe581 Override Fault() method for VM{Device,Null}Cache to prevent vm_soft_fault()
from inserting a clean page, if a fault happens. VMNullCaches are used by the
slab's memory manager -- all page faults in slab areas are serious bugs and
we want to panic() immediately.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35748 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-03 22:08:47 +00:00
Stefano Ceccherini
08876f2b96 Move the code which checks for disabled apic earlier (in the boot loader).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35741 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-03 19:14:42 +00:00
Axel Dörfler
88f1263865 * The slab_cache command now also dumps the actual slab lists.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35737 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-03 15:15:49 +00:00