Commit Graph

1116 Commits

Author SHA1 Message Date
Axel Dörfler
871d97a9f5 * Fixed the kernel bug that prevented SIGCONT from working properly: the problem
occured if SIGSTOP was already delivered but not yet handled when SIGCONT was
  sent. Now, SIGCONT will clear all stop signals from the pending signals.
* SIGTSTP, SIGTTIN, and SIGTTOU are supposed to suspend the thread as well, adapted
  the default behaviour to respect that.
* Removed the work-around from r21997 TermParse.cpp for this exact problem.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22004 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-17 13:08:24 +00:00
Axel Dörfler
a728651f04 Some more work on the signal code:
* get_signal_stack() checked the wrong sig_action field (index is signal-1), also,
  it had an off-by-one error in the stack range check.
* factored out a restart_syscall() function to avoid code duplication
* arch_setup_signal_frame() relied on the fact that vregs and the signal stack code
  is a multiple of 4 bytes in size.
* Fixed sigaction(): it did return the error code directly instead of setting errno.
* signal() actually had a work-around for the broken sigaction()...
* Replaced the sig_func_t typedef with a sighandler_t typedef - this is non-standard
  anyway, but now we're at least compatible with the GNU world instead of introducing
  our own solution (BSD seems to use sig_t here, BTW).
* Removed now unused sigval structure from the header; it should be added again as
  soon as we start supporting it.
* SA_RESETHAND and SA_ONESHOT are the same thing; the former did not work before.
* Made the non-standard SA_* flags refer to the standard ones instead of the other
  way around.
* Added a test application for various signal features - works fine under Haiku,
  tested also under Linux and BeOS (the latter fails as it does not support SA_RESTART).
  More tests should be added, though.
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21999 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-17 11:01:09 +00:00
Axel Dörfler
0b70ea5992 * Implemented sigaltstack() and set_signal_stack(), thus closing bug #1401.
* On exec() the new function thread_reset_for_exec() is called which clears the signals
  and cancels an eventually set alarm. Both things weren't done before...
* Some minor cleanups.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21989 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-16 18:01:47 +00:00
Axel Dörfler
a2e2784cf3 * arch_restore_signal_frame() accessed user memory unsafely; it now also copies the (pretty
large) vregs structure to the stack.
* Introduced a get_signal_stack() function that arch_setup_signal_frame() now uses to setup
  the signal frame - it currently only returns the default user thread stack. Also made
  sure arch_setup_signal_frame() is independent from the user stack.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21983 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-16 15:11:58 +00:00
Axel Dörfler
066a557444 * vm_soft_fault() no longer sets all pages it touches to "active"; instead, it now honours
if the page was already in the "modified" list before. Also, the source page (which is
  either mapped directly or copied to the target page) is no longer marked busy before its
  final destiny is decided (it didn't have any effect, anyway, since we had its cache
  locked for the whole time, but it now preserves the modified state). This fixes bug #1369.
* vm_cache_write_modified() now filters out temporary caches (it's currently called on area
  deletion).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21971 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-15 23:11:15 +00:00
Ingo Weinhold
337171e417 Fixed the documentation.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21917 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-12 23:54:15 +00:00
Ingo Weinhold
5c806b5dbc map_backing_store() would deadlock in error case for REGION_PRIVATE_MAP.
Closes #1379.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21914 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-12 22:32:23 +00:00
Ingo Weinhold
2529455101 Revised the AVLTreeMap code:
* Pulled the actual tree code into a non-templatized class AVLTree to
  reduce the amount of code generated each time the template is
  instantiated.
* Changed the iterator interface to Java-style.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21892 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-11 14:57:25 +00:00
Ingo Weinhold
13542314ef Removed special dummy page handling. It became obsolete with r21816,
since fault_find_page() does no longer insert a dummy page into a cache
that has a store from which it can read the page.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21887 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-11 00:31:14 +00:00
Ingo Weinhold
279c6b76dc * Use condition variables when waiting for busy pages or busy caches.
* Removed a few instances where the page state was set busy directly after 
  allocating it. This is a no-op, since a page is always busy after 
  allocation.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21875 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-09 20:08:25 +00:00
Ingo Weinhold
227402f2bf Added simple condition variables to the kernel. They are a relatively
cheap means to block threads until notified explicitely.
threads 


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21874 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-09 20:03:17 +00:00
Axel Dörfler
a2057fac93 Since get_memory_map() can run with interrupts turned off, it can't put up
it's reference to the vm_address_space - luckily, it doesn't even need a
reference, since it always runs in the current address space, which cannot
go away for obvious reasons.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21865 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-08 23:51:20 +00:00
Axel Dörfler
69bee56c3b * get_memory_map() leaked vm_address_space references
* fixes a dead lock in vm_soft_fault() - the locking scheme enforces you to
  lock the address space before a vm_cache, not the other way, around. Since
  we need to lock the cache that has our page in fault_get_page(), we violated
  that scheme by relocking the address space in order to get access to the
  vm_area. Now, we read lock the address space during the whole page fault;
  added a TODO that explains why this might not really be desirable, if
  we can avoid it (the only way would be to reverse that locking scheme
  which would potentially cause the more busy vm_cache locks to be held
  longer).
* vm_copy_area() uses the MultiAddressSpaceLocker, but actually forget to
  call Lock() on it...
* delete_area() leaks vm_address_space references - but fixing this currently
  causes other problems to be investigated; I'll open a bug for that.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21862 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-08 22:38:46 +00:00
François Revol
e0475f8f7e Fix building with TRACE
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21861 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-08 21:44:30 +00:00
Axel Dörfler
5af1dda793 bonefish+axeld:
* Removed the ref_count from vm_areas. You now always need to have the address
  space locked (read or write, depending on what you do) when dealing with
  areas.
* Added helper classes for locking the address space: AddressSpace{Read|Write}Locker,
  and MultiAddressSpaceLocker which can lock several spaces at once and makes
  sure no dead locks can happen.
* resize_area() is now using the MultiAddressSpaceLocker instead of no locking
  at all; ie. it should now be safely to use.
* Disabled transfer_area() for now; it will be changed to work like an atomic
  clone_area()/delete_area(), that is, it will hand out a new ID for the
  transfered area.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21848 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-07 21:46:58 +00:00
Axel Dörfler
7e188a5b4b Now prints a more detailed message in case the kernel stack couldn't be created.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21847 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-07 01:54:08 +00:00
Ingo Weinhold
2ac748daf1 * Changed the signatures of fault_get_page() and fault_find_page(), so
that an error can be propagated back to vm_soft_fault().
* Added boolean restart reference parameter to fault_find_page() which
  is set to true whenever a condition is it encountered that requires
  to start fault_find_page() from the very beginning. fault_get_page()
  checks the flag and executes fault_find_page() in a loop, now.
* Removed the panic()s+TODOs in fault_find_page() when a cache became
  busy. The restart feature is used in this case.
* fault_find_page(): If after the loop we haven't found a page yet,
  and after locking the right cache one turned up, we restart the
  function, too, thus avoiding double insertion of a page into a cache.
* Fixed potential dead-lock in fault_get_page(): After inserting a clean
  page into a cache other than the top cache (read fault on
  copy-on-write area not backed by a file (e.g. the heap)) the dummy
  page was removed from the to be locked top cache while we still held a
  lock for the lower cache, thus inverting the locking direction
  required by the cache locking policy (top -> bottom).
* fault_get_page(): In case of a write access and a readable page found
  in a lower cache, vm_cache_remove_consumer() could have replaced our
  dummy page with a real page from a collapsed lower cache while we
  had unlocked both caches. We didn't check for this condition and
  always inserted our freshly allocated page, thus potentially inserting
  a duplicate page into the top cache. We do the check now and discard our
  page, when another page turned up. Fixes bug #1359.
* fault_get_page(), same if block: Removed unused case for removal of the
  dummy page from a non-top cache. We only ever insert it into the top
  cache and it should not be moved to another cache. Added an assert.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21841 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-06 18:06:01 +00:00
Axel Dörfler
f58cf973ad mmlr+bonefish(+axeld - I put the bug in there ;-)):
* Inode::MayReleaseWriter() would release the semaphore too often; therefore,
  Inode::WriteDataToBuffer() now loops in case it still couldn't write anything
  instead of failing - this fixes a race condition (ie. a device is full message).
* In case the read request got filled two times (while adding the request, and
  after waiting for it to become filled), ReadRequest::PutBuffer() overwrote the
  output data. This fixes bug #1331.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21830 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-05 23:38:31 +00:00
Marcus Overhagen
d1dc70fa5f FD_CLOEXEC is a flag, other bits may be set
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21829 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-05 13:56:01 +00:00
Ingo Weinhold
fd772abcb4 Paranoia: vm_cache_insert_page() does now check whether a page for the
offset of the page to insert is already in the cache. Revealed the bug
fixed with my previous commit.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21817 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-04 00:36:50 +00:00
Ingo Weinhold
0a75dab5fe fault_find_page(): Fixed a race condition in case of reading the page
from the store into the top cache, which could lead to pages inserted
multiple times into the cache. We don't insert a dummy page in this case
anymore. Instead we mark a freshly allocated page busy and insert that
one. That's exactly the approach the file cache uses too. This does
probably make the whole dummy page special handling in the file cache
obsolete.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21816 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-04 00:33:47 +00:00
Ingo Weinhold
7c3a45ec5e Although probably not used ATM, cache_prefetch_vnode() should respect
busy pages.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21815 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-04 00:24:13 +00:00
Axel Dörfler
e9012605b8 vfs_get_vnode_cache() was changed (read: fixed) since r18716; it was wrong
to acquire the extra vnode reference, and actually prevented unmounting from
working - which it now does again.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21806 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-03 01:26:35 +00:00
Axel Dörfler
171d3a85cb * Made the module code more robust against putting more module reference
than you own - instead of crashing some time later, it will now panic as
  soon as it can.
* No longer put the module image for B_KEEP_LOADED modules - essentially,
  that feature was broken.
* Now use the RecursiveLocker in favour of manual locking where appropriate.
  This actually fixed two locking bugs in error code paths.
* Applied a patch by François Revol: open_module_list() did not work
  when the prefix was already inside a module (as opposed to a directory
  on disk). The current solution is not as efficient, but that can be
  fixed by improving the iterator code.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21803 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-02 21:44:54 +00:00
Ingo Weinhold
9e12e9a72e * Added mapping of dup() in the FS shell.
* Adjusted the FS initialize() hook to have FD and partition_id
  parameters like the other hooks instead of the partition path.
* Adjusted initialization in BFS accordingly.
* Implemented the FS initialization method in KFileSystem.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21788 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-02 12:43:49 +00:00
Ingo Weinhold
6b7bedcbee axeld + bonefish:
Certain interrupts don't disable interrupts. We were calling 
x86_{push,pop}_iframe() without specifically disabling them, thus causing 
a race condition with could cause the iframe stack to be invalid. This 
could cause all kinds of problems.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21784 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-02 02:48:11 +00:00
Ingo Weinhold
e786c1d6a9 axeld + bonefish:
After exec() we re-entered the userland without removing the syscall
iframe from the iframe stack, thus leaking one stack slot.
Fixes bug #1304.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21783 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-02 02:37:35 +00:00
Axel Dörfler
463be7ab63 Extended the "last acquirer" debug stuff to also contain the thread that
released it last, and the counts involved.
Furthermore, release_sem_etc() will now only negate the acquirer thread
ID instead of setting it to -1.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21781 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-01 16:46:24 +00:00
Axel Dörfler
edb15b5565 bonefish+axeld:
* Simplified the notification framework: removed the updater stuff completely;
  it was only there to account for some peculiarities of the node monitor which
  we now solved differently.
* NotificationListener no longer includes a doubly linked list link for convenience;
  it might want to listen to more than just one service.
* NotificationService cannot have an abstract destructor.
* Changed the _user_stop_watching() syscall to mirror the Be API; ie. it's no
  longer possible to just remove some flags separately, just to stop listening
  completely.
* Adapted the node monitor implementation to live in the NodeMonitorService class
  that uses the new notification framework.
* Removed the public kernel node monitor API - it wasn't useful that way since you
  couldn't do a lot with the KMessage in the kernel without using a private API.
  Now you will have to use the (private) notification manager to use the node monitor
  from inside the kernel. At a later point, we might introduce a public API for that,
  too.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21780 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-01 14:48:44 +00:00
Axel Dörfler
a898ee19d6 Ahem... build fix. Forgot that there were some last minute changes that shouldn't have been part of the commit...
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21773 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-31 17:17:51 +00:00
Axel Dörfler
bec0386d82 bonefish+axeld: Implemented a robust notification framework for the kernel.
Will be used for node monitoring and other stuff, too (like the Registrar or the
VM low memory handler).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21768 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-31 16:23:40 +00:00
Axel Dörfler
8405223037 axeld+bonefish: Got rid of the ParentType in the HashTableDefinition; it doesn't really
belong there.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21766 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-31 16:14:58 +00:00
Axel Dörfler
6e09c5679e area_for() in the kernel can now also find user areas in case you are coming from a user team.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21746 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-30 11:54:11 +00:00
Axel Dörfler
4bef3723a1 * Followed Ingo's suggestion and send the message manually in the runtime loader;
therefore, we could remove the ugly defines from KMessage again, and compile it
  with KMESSAGE_CONTAINER_ONLY.
* Added KMessage::SetDeliveryInfo() to be able to send messages with a correct
  header.
* Fixed a bug in KMessage::SendTo() that would not send the senderTeam when passing
  a negative value for the parameter, but override it when passing in a valid
  value.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21740 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-29 21:36:49 +00:00
Marcus Overhagen
4e7050cd09 Allow thread priority setting from inside kdl. Right now, a
single priority 12 thread can make the whole GUI appear frozen.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21736 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-29 01:30:59 +00:00
Marcus Overhagen
3ab19002fe Added "suspend", "resume" and "drop" commands to kernel debugger.
It's now possible to debug amok-running user threads by 
suspending or resuming them, as well as dropping them into 
the userland-debugger from inside kdl.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21734 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-29 01:06:36 +00:00
Marcus Overhagen
8f5e97473f build fix (rebuidling MessagingService.o wasn't possible after this jamfile was changed in r21715)
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21733 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-29 00:51:36 +00:00
Marcus Overhagen
2e53897578 kernel debugger support for suspending a thread
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21732 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-29 00:24:54 +00:00
Marcus Overhagen
71ec907eaa Build fix for GCC 4
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21731 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-28 22:36:02 +00:00
Ingo Weinhold
d86af8ce27 * Style cleanup.
* Moved method documentation from headers to source files.
* Fixed small problems (memory leaks, unsafe string duplication,...).
* Added TODOs where I spotted problems.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21721 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-27 16:32:47 +00:00
Ingo Weinhold
e098680c08 Missed those in the previous commit.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21720 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-27 15:37:23 +00:00
Ingo Weinhold
2dc6403ddc Addition of write support to the disk device manager. Courtesy of Tomas
Kucera and Jan Matejek.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21719 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-27 12:12:35 +00:00
Axel Dörfler
74c0424a43 * Added a mechanism to retrieve a BMessage with eventual error descriptions
for _kern_load_image().
* Added KMessage to the runtime_loader (a bit hacky, though) - it will use
  it to deliver the above mentioned functionality.
* load_dependencies() did return the wrong status code in case a library
  was missing; now it returns B_MISSING_LIBRARY.
* load_dependencies() will now try to load all dependencies when a report
  message is requested; therefore, all missing libraries are listed.
* Renamed uspace_program_args to user_space_program_args.
* The kernel filled in various members of the user_space_program_args structure
  unsafely, ie. was not using user_memcpy().
* Renamed some local variables in team.c to better fit our style guide (ie.
  uargs to userArgs).
* Changed Tracker to use the new _kern_load_image() variant on Haiku to retrieve
  and report all missing libraries. This fixes bug #1324.
* Adapted kernel_cpp.cpp to the runtime loader as well; the latter will now
  compile with _LOADER_MODE defined.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21715 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-27 02:32:19 +00:00
Axel Dörfler
d6dfbc4de5 Minor cleanup in comments.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21714 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-27 02:15:39 +00:00
Axel Dörfler
266528b633 read_port[_etc]() now allows the msgCode pointer parameter to be NULL - as on BeOS.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21712 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-27 01:34:14 +00:00
Marcus Overhagen
ba8c1ff561 Make partition access saver. attempts to read or write outside of a partition
now fail with B_BAD_VALUE. It's also no longer possible to overwrite the begin
of a partition by specifying a negative position, as negative positions are no
longer translated into 0.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21702 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-25 22:30:59 +00:00
Axel Dörfler
528e58c58e Fixed debug output.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21689 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-23 00:52:07 +00:00
Ingo Weinhold
6d1c68155a axeld + bonefish:
* More conditional debug code (wrt page transitions between caches).
* Replaced debugger command cache_chain by a nicer cache_tree.
* While handling a soft fault: When we temporarily unlock a cache, it
  can theoretically become busy. One such occurrence is now handled
  properly, two more panic() ATM, though should be fixed.
* When merging caches, we do now always replace a dummy page in the
  upper cache, not only when the concurrent page fault is a read fault.
  This prevents a page from the lower (to be discarded) cache from still
  remaining mapped (causing a panic).
* When merging caches and replacing a dummy page, we were trying to
  remove the dummy page from the wrong cache (causing a panic).

The Haiku kernel seems now to run shockingly stable. ATM, we have more
than two hours uptime of a system booted and running over network. We
didn't manage to get it down by fully building Pe, downloading, unzipping,
and playing with various stuff. Someone should finally fix all those app
server drawing bugs, though (hint, hint! ;-)).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21672 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-19 22:52:23 +00:00
Ingo Weinhold
fec9ab5d63 More informative output.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21669 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-19 21:43:22 +00:00
Ingo Weinhold
f4da50b768 Computed the netmask in net endianess. The wrong netmask caused
misrouting when the net server set up the loop device, thus stopping the
net boot process.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21662 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-19 13:58:17 +00:00
Ingo Weinhold
210ea8a561 axeld + bonefish:
Answered Travis question. We save the registers from the exception
causing the double fault in the double fault iframe, since otherwise it
would contain only completely unusable values.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21661 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-19 13:55:56 +00:00
Ingo Weinhold
9c31fe7e21 Implemented emulating write_pages() using the write() hook.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21658 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-19 13:35:53 +00:00
Ingo Weinhold
fe679b9fa7 axeld+bonefish:
* Refactored RescanDiskSystems(). Pulled out a function
  _RescanDiskSystems() that scans for either file or partitioning
  systems. RescanDiskSystems(), which scanned for file systems only
  before, is used from the constructor as well (open_module_list()
  works in the early boot process since a while).
* Made InitialDeviceScan() and partition scanning safe to be called a second
  time. We call it directly after the kernel has mounted the boot
  volume, now, so that additional disk systems from the boot volume have a
  chance to recognize previously unrecognized partitions. This is a
  temporary change only; later the disk device manager shall
  automatically find out when new disk systems/devices/whatever are
  available.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21655 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-19 13:32:33 +00:00
Ingo Weinhold
17a5219dba bonefish+axeld:
When loading the driver settings the defaults don't override the
previous variable values anymore.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21654 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-19 13:16:08 +00:00
Axel Dörfler
0379077f09 * init_double_fault() accidently initialized the wrong TSS for the handler (the regular
one, not the one intended for the double fault) since r20131. IOW double faults are
  now working again.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21645 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-18 12:40:38 +00:00
Axel Dörfler
58f6e8e5e4 * Merged vm_cache_ref and vm_cache to a single structure (Axel & Ingo).
* Renamed vm_cache.c to vm_cache.cpp


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21642 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-18 00:16:27 +00:00
Axel Dörfler
1296365693 Minor cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21641 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-17 23:40:41 +00:00
Ingo Weinhold
1fa400cd92 The partition offset is int64, of course, not bool. Sometimes one wishes,
C++ had a stricter typing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21624 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-16 15:06:02 +00:00
Axel Dörfler
3a199128de * Now checks if the BootMethod allocation succeeds.
* Minor cleanup, reordered header files to go from private/local to public/global.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21623 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-15 23:51:21 +00:00
Axel Dörfler
bd1877933f remove_vnode() will now return an error code if the vnode to be removed did not exist.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21614 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-15 12:38:13 +00:00
Ingo Weinhold
f29a0687cf We were leaking a module reference.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21613 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-15 02:29:00 +00:00
Ingo Weinhold
9e8dc2a9bb [Sorry, couldn't split this one up any further.]
* Images preloaded by the boot loader had to be modules to be of any use
  to the kernel. Extended the mechanism so that any images not accepted
  by the module code would later be tried to be added as drivers by the
  devfs. This is a little hacky ATM, since the devfs manages the drivers
  using a hash map keyed by the drivers inode ID, which those drivers
  obviously don't have.
* The devfs emulates read_pages() using read(), if the device driver
  doesn't implement the former (all old-style drivers), thus making it
  possible to BFS, which uses the file cache which in turn requires
  read_pages(), on the device. write_pages() emulation is still missing.
* Replaced the kernel_args::boot_disk structure by a KMessage, which can
  more flexibly be extended and deals more gracefully with
  arbitrarily-size data. The disk_identifier structure still exists,
  though. It is added as message field in cases where needed (non net
  boot). Moved the boot_drive_number field of the bios_ia32 platform
  specific args into the message.
* Made the stage 1 PXE boot loader superfluous. Moved the relevant
  initialization code into the stage 2 loader, which can now be loaded
  directly via PXE.
* The PXE boot loader does now download a boot tgz archive via TFTP. It
  does no longer use the RemoteDisk protocol (it could actually be
  removed from the boot loader). It also parses the DHCP options in the
  DHCPACK packet provided by PXE and extracts the root path to be
  mounted by the kernel.
* Reorganized the boot volume search in the kernel (vfs_boot.cpp) and
  added support for network boot. In this case the net stack is
  initialized and the network interface the boot loader used is brought
  up and configured. Since NBD and RemoteDisk are our only options for
  net boot (and those aren't really configurable dynamically) ATM, the
  the boot device is found automatically by the disk device manager.

Booting via PXE does work to some degree now. The most grievous problem
is that loading certain drivers or kernel modules (or related activity)
causes a reboot (likely a triple fault, though one wonders where our
double fault handler is on vacation). Namely the keyboard and mouse input
server add-ons need to be deactivated as well as the media server.
A smaller problem is the net server, which apparently tries to
(re-)configure the network interface we're using to boot, which
obviously doesn't work out that well. So, if all this stuff is disabled
Haiku does fully boot, when using the RemoteDisk protocol (not being
able to use keyboard or mouse doesn't make this a particular fascinating
experience, though ;-)). I had no luck with NBD -- it seemed to have
protocol problems with the servers I tried.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21611 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-15 02:10:15 +00:00
Ingo Weinhold
3532662e0c Added RemoveLeaf() leaf method. Very handy for recursive directory
iteration code using a single KPath object.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21606 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-15 00:34:17 +00:00
Ingo Weinhold
dad631290c * Made header includable by C code. In this case a KMessage structure
with the same size as the class is defined.
* The SetTo() methods do now accept an unspecified (negative) bufferSize
  in case of being told to initialize from the given buffer.
* Added handy Get*() methods returning a field element value or a
  supplied default value, if the field element doesn't exist.
* Added also handy Set*() methods setting the value of first element of
  a field, i.e. adding it, if it didn't exist before, otherwise
  replacing the old value. Only for fixed size types.
* Moved _FindType() inline template method into the header.
* Made the source file fit for use in the boot loader. If the macro
  KMESSAGE_CONTAINER_ONLY is defined, the message sending/receiving part
  is omitted.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21605 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-15 00:32:37 +00:00
Axel Dörfler
9958d12db2 Because of ongoing problems with thread_yield() and our current scheduler, I've disabled yielding for now; it will now just snooze a bit.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21572 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-05 18:27:27 +00:00
Axel Dörfler
d5a279fef8 Cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21552 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-04 17:33:22 +00:00
Axel Dörfler
25f46ea449 * Reserving areas never put down their reference of their address space when
removed in several cases.
* vfs_get_vnode_cache() now always gives out a reference to the cache it
  returns; if it needs to allocate a new one, the vnode owns one reference,
  and the caller another.
* therefore, file_cache_create() now owns a reference to its vm_cache_ref, and
  frees it in file_cache_delete().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21533 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-06-30 15:36:06 +00:00
Axel Dörfler
a492532bd9 Get rid of outdated and mostly useless docs, updated some of the comments in the source.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21529 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-06-30 13:58:41 +00:00
Ingo Weinhold
a970df44af * Include HaikuImage after the Jamfiles, so they can provide/adjust info
relevant for the image creation.
* The CopySetHaikuRevision propagates the value of the
  HAIKU_INCLUDE_IN_IMAGE variable from the source to the target.
* Propagate the value of HAIKU_INCLUDE_IN_IMAGE from "kernel" to
  "kernel_$(TARGET_ARCH)".

Now "jam update-install kernel" should work as expected.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21527 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-06-29 19:28:11 +00:00
Axel Dörfler
245aecda8a Got rid of vnode_id and mount_id, replaced with ino_t and dev_t.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21485 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-06-21 19:50:57 +00:00
Axel Dörfler
0cb94db539 Ingo and I fixed a couple of VM bugs in a late night debugging session:
* vm_copy_on_write_area() now does no longer overwrite the ref_count, but keeps
  it's reference to the cache until it has unlocked it.
* It now also locks its reference from the start, preventing any other thread
  to interfere.
* vm_cache_remove_consumer() now detects if it has to remove a foreign busy
  page itself in order to preserve a mapped page.
* vm_soft_fault() now keeps a reference to the cache that owns the page to be
  mapped until it has actually mapped it.
* vm_unmap_pages() removed the mappings of all pages of the area instead of only
  those that are within the requested range.
* Kept (disabled) debug output for convenience.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21482 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-06-21 13:57:46 +00:00
Axel Dörfler
8491616029 Putting an unused block will now trigger a panic.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21481 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-06-21 12:35:39 +00:00
Travis Geiselbrecht
c9788912f0 re-enable kernel asserts.
Disabled by default, but all kernel devs are *highly* recommended to turn them on for your builds and see if it trips anything, and then fix it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21477 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-06-21 05:37:46 +00:00
Travis Geiselbrecht
554fdaa33a Fix a bug that was tripping an assert in the kernel module code.
When iterating through modules, the iterator was loading the module file, inserting it into the module image hash. Then, the first time get_module() was called on a module contained in the image, it was trying to load the image again. It probably actually was. Changed the logic to call get_module_image() which checks to see if it's already loaded.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21476 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-06-21 05:07:14 +00:00
Axel Dörfler
5de78b2cdb Added some temporary means to ease debugging block caches - at least the list
of all caches should be removed at a later point.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21461 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-06-18 23:58:15 +00:00
Stefano Ceccherini
d9be8bc0fe Got rid of a global, hope no one minds
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21349 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-06-08 09:44:13 +00:00
François Revol
fc362b8ad7 handle api_version exported from driver.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21344 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-06-07 12:46:20 +00:00
Axel Dörfler
b851137be0 * Now replaces the first argument with the actual function name as find_command()
also works for partial matches (which for example broke "running" and "ready"
  when you only entered a part of it).
* Renamed the global args pointer to sArguments.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21324 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-06-04 22:31:24 +00:00
Stefano Ceccherini
1c86f4892b Renamed a couple of variables, for easier reading...
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21319 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-06-04 12:20:58 +00:00
Axel Dörfler
8d1317e1b6 get_next_loaded_module_name() now uses the same (inefficient) mechanism read_next_module_name() is using thanks to Siarzhuk - the previous mechanism was completely unsafe.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21316 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-06-03 23:09:59 +00:00
Axel Dörfler
65c61fbf2d * Applied a patch by Siarzhuk Zharski that allows open_module_list() to be
used during early boot. Thanks!
* Fixed open_module_list() so that it can deal with a NULL prefix.
* Added a note that get_next_loaded_module_name() is implemented incorrectly.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21315 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-06-03 22:55:09 +00:00
Axel Dörfler
176f0604ed Continuing from the kernel debugger did not work on SMP machines, as SMP_MSG_CPU_HALT was
a one way ticket. It now works as expected.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21280 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-31 22:09:39 +00:00
Axel Dörfler
9b39fc10cb Cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21279 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-31 22:05:57 +00:00
Axel Dörfler
f415aa28be * create_vnode() now panicks when it could not find the freshly created vnode
in the vnode hash; that's a bug in the FS that shouldn't be ignored that way.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21262 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-28 14:17:18 +00:00
Axel Dörfler
aac3ed8c03 * Reverted r21199 (and therefore r21254) - it actually did work correctly initially,
see bug #1248.
* Closing a pipe now also removes it from the public namespace and marks it for
  deletion, and thus, there are no more left-overs after using a pipe.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21261 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-28 14:12:43 +00:00
Jérôme Duval
6015e60ecc fixed bug #1248
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21254 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-27 19:57:09 +00:00
Jérôme Duval
b5f602a702 added a missing newline, dunno why this message is displayed :)
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21250 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-27 14:25:49 +00:00
Hugo Santos
6580fd3848 Stylus cleanupus.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21224 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-23 21:48:31 +00:00
Hugo Santos
77bf99deb0 fixed the way accept() works in regards to the cookie pointer. It is no longer visible to userspace, we pass the fd instead. Also renamed kernel's shutdown() to system_shutdown as it collides with Posix's shutdown().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21223 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-23 19:56:40 +00:00
Axel Dörfler
01e7c0d868 You should not publish *every* node - at least not without releasing the ref if you don't need it.
This should allow you to actually unmount /pipe if you so desire.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21199 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-22 01:56:45 +00:00
Axel Dörfler
6430c89618 * Added find_directory() to the kernel - it currently may not work as good as the
userland version, tbough.
* Small style cleanup in find_directory.c.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21194 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-21 22:28:02 +00:00
Ingo Weinhold
bdf8a2e1e7 Added Haiku revision number to the kernel (same mechanism as used for
libroot). It's available in the kernel through the private
get_haiku_revision() and added to the kernel syslog output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21173 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-19 15:36:32 +00:00
Axel Dörfler
8ca5764554 * Implemented APM generic syscall API to query the current power status.
* PowerStatus is now using this API when compiled for Haiku.
* Note, I'm not sure why yet, but running PowerStatus in the background
  crashes at least my laptop after some time.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21154 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-16 15:22:23 +00:00
Axel Dörfler
6f709e745c * Added a name hash to pipefs; this should speedup the lookup when more pipes
are used at the same time.
* Added a TODO item: pipefs entries aren't deleted yet after usage!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21108 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-11 09:16:08 +00:00
Hugo Santos
cdb3eb762a the previously added IO interrupt handling routines are no longer necessary, at least for now.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21046 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-06 22:40:52 +00:00
Hugo Santos
5502e596dc added io_interrupt_handler methods for dynamic handling of IO interrupts, including enabling/disabling without allocation and in interrupt context.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21040 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-06 15:07:56 +00:00
Jérôme Duval
c0ca505fb0 devfs now accepts to create directories
is scanning needed here ?


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20982 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-02 19:04:06 +00:00
Marcus Overhagen
3d65babaa6 restore previous serial debug output setting when leaving kernel debugger
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20955 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-01 18:13:01 +00:00
Marcus Overhagen
cafc95e0af Make no-settings-file defaults match the empty-settings-file defaults.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20950 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-01 13:00:33 +00:00
Hugo Santos
8cfe0be38e slab/cache: a couple more fixes.
- on CACHE_DURING_BOOT init benaphore count with 1.
 - account for allocated space on early_allocate_pages.
 - fixed slab position calculation in small slabs.
 - we can now init all allocator sizes early rather than later.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20914 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-30 01:08:05 +00:00
Hugo Santos
698b6d7195 cache/slab: when CACHE_DURING_BOOT is specified, use vm_allocate_early to obtain pages for slabs, and create the associated areas on post bootup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20913 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-29 22:58:46 +00:00
Hugo Santos
39af445966 added object_cache_reserve to allow cache users to pre-allocate slabs.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20912 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-29 21:45:23 +00:00
Hugo Santos
11debaf6e4 added CACHE_UNLOCKED_PAGES flag to allow caches' pages to be created with no locking instead of full locking.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20911 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-29 20:55:44 +00:00
Marcus Overhagen
d995743822 Enabled syslog debug output by default, added new syslog options to config file.
Reversed arguments in kernel settings file, now you only need to uncomment a line
to get the non-default setting. Explained default setting in comments.     


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20907 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-29 17:22:08 +00:00
Hugo Santos
14342a6767 cache allocator: keep allocation waste statistics. added debugger command 'show_waste'.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20903 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-29 15:28:31 +00:00
Hugo Santos
c49aa60ace cache allocator: for allocations > 8k create areas, and delete them on free.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20902 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-29 15:13:09 +00:00
Hugo Santos
0be6e97788 minimal cleanups
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20901 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-29 13:11:30 +00:00
Hugo Santos
9a9cba598a don't need TRACE_SLAB by default now.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20898 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-29 03:41:10 +00:00
Hugo Santos
172b3066aa fixed the cache allocator's size_to_cache.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20897 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-29 03:33:51 +00:00
Hugo Santos
6bad493439 pushed the slab init a bit deeper. added a object cache based allocator, including a bootstrap mechanism to have it init during bootup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20896 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-29 02:23:37 +00:00
Hugo Santos
6e31ae98f9 some object cache / slab improvements.
- call the reclaimer callback when low on memory.
 - use the depot when on multi-cpu setups (for scalability).
 - fixed the amount of memory spent on slabs for very large objects.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20889 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-28 21:35:23 +00:00
Hugo Santos
11b5020f2f rewrote the object cache (slab) implementation a bit, preparing for further integration.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20887 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-28 18:53:58 +00:00
Hugo Santos
8a96ba39e3 some slab cleanups, split the C interface to another file.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20875 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-28 09:37:38 +00:00
Ingo Weinhold
5b1cb74b86 Even more correct return value.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20856 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-27 10:47:21 +00:00
Ingo Weinhold
93ed453113 More correct return value.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20855 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-27 10:45:57 +00:00
Hugo Santos
0cd08b100c ups, TRACE_SLAB was on.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20852 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-27 08:07:30 +00:00
Hugo Santos
5d6551d69f removed some of the slab's initial heavy debugging. we now merge the links into the slab itself resulting in zero overhead per buffer with MergedLink strategy.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20841 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-26 15:40:53 +00:00
Hugo Santos
d7ae189ecf slab: be smarter when picking the underlying strategy for the slab C API (based on requested object size).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20840 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-26 12:21:38 +00:00
Hugo Santos
e6fb3d3947 more slab fixes, also introduced a new strategy optimized for medium sized buffers (64 >= x < 512) with lengths other than power of 2 (has an overhead of 2 words per buffer).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20839 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-26 11:38:24 +00:00
Hugo Santos
dd89ad0e7e added locking to slab's Cache<>. Now we react to system's low memory conditions freeing up empty slabs.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20836 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-26 07:31:19 +00:00
Hugo Santos
81bc570922 assorted slab fixes.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20833 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-26 06:05:08 +00:00
Hugo Santos
81423c91c7 added initial slab code to the kernel. It is still unused, and there is still no VM interaction.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20832 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-26 03:41:24 +00:00
Axel Dörfler
5c03270bea Added block_cache_sync_etc() that allows you to sync single blocks.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20811 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-25 12:07:30 +00:00
Axel Dörfler
6d1144bbca The thread context was destructed a bit too early: if a team was killed (or didn't
close all of its file descriptors), code outside of the core kernel would be executed
in the descriptor's close/free hooks.
Since the semaphore timeout code, and send_data()/receive_data() rely on the
thread being available in the thread hash, they wouldn't work anymore.
This fixes bug #1168. Thanks to Marcus for providing such a nice test case :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20808 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-25 08:25:10 +00:00
Axel Dörfler
1c4b5b8a6a Added a debugging command "devfs_node" to dump infos about the private devfs nodes for now.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20794 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-24 14:04:26 +00:00
Axel Dörfler
be1f432648 Don't allow creating areas with a size of 0 bytes, courtesy of Vasilis Kaoutsis.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20789 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-23 22:22:29 +00:00
Axel Dörfler
9504919814 Disabled priority boost on semaphore release completely now (after having pacified it
quite a bit in the past already); it somehow doesn't work right with how semaphores
are used in BeOS/Haiku.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20759 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-19 21:30:38 +00:00
Axel Dörfler
22428cc7b6 * More or less reverted my previous thread_yield() change: while this gives
threads with higher priorities a much better scheduling experience, it
  also creates a problem as soon as more than one higher priority thread
  waits on a resource held by a lower priority thread; the higher priority
  threads play ping-pong, and the lower priority thread doesn't get it's
  chance.
* Increased the probability of skipping a thread priority.
* I won't do any other changes on the scheduler, that's meianote's job now :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20758 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-19 21:25:19 +00:00
Travis Geiselbrecht
3095921098 asm optimized user_memcpy(), which should help somewhat, since the old version was a byte-by-byte copy.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20723 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-16 06:48:38 +00:00
Travis Geiselbrecht
831486a2d3 Turn the assembly optimized memcpy (simple rep movsd) back on for x86. Had to hack around the make system a bit, and the result is pretty nasty, specifically due to the amount of places in the system where various targets poke their fingers into the libroot directory.
The solution is less than optimal, but should work for now.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20722 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-16 06:17:14 +00:00
Axel Dörfler
861b3c0b6f The busy page could also be in another cache that is layered upon the merged one,
so we can't easily check if the remaining mappings are valid - therefore I disabled
the check completely.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20654 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-11 15:50:11 +00:00
Axel Dörfler
1407f23d9b * The test for existing mappings in vm_remove_consumer() was a bit too aggressive;
if the page is currently copied, the source page still has mappings.
* vm_copy_on_write_area() did not set the cache type for the upper cache.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20530 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-03 11:23:37 +00:00
Ingo Weinhold
1e768ed1d3 get_vnode_name():
* read_dir() is supposed to return B_OK and and a count of 0 when
  reaching the end of the directory. In case the node in question could
  not be found, we were looping infinitely.
* free_dir_cookie() was not invoked.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20519 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-03 04:29:24 +00:00
Axel Dörfler
70a11cecbd * pages_io() now handles it gracefully in case the fileVec array is too
small to hold the information for the requested I/O size.
* get_file_map() returned B_BUFFER_OVERFLOW already in case the array
  was exactly as large as needed.
* read_chunk_into_cache() and write_chunk_to_cache() will no longer
  override their local "size" variable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20509 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-02 11:13:03 +00:00
Ingo Weinhold
962b0b887d Added a wrapper function for the invocation of debugger commands. It
sets a fault handler, so that an invalid memory access while executing
the command (address typos always do the trick :-) won't result in
another KDL session on top of the current one, which wouldn't even be
"cont"able.

All pieces of code setting a fault handler do now save and reset the
previous one, so that e.g. a user_memcpy() in a debugger command doesn't
disturb the mechanism.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20500 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-01 17:15:37 +00:00
Ingo Weinhold
9bf1f552d9 Enabled setjmp()/longjmp() support in the kernel.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20499 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-01 17:05:26 +00:00
Ingo Weinhold
6e442c70cb Reversed locking order of sImageLoadMutex and sImageMutex in
unload_kernel_add_on(). The former one could lead to deadlocks with
load_kernel_add_on() (e.g. occasionally the boot process would hang).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20485 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-31 23:06:09 +00:00
Ingo Weinhold
57a860987a A few more changes to pages_io():
* Added a few comments.
* Simplified the nested while loops by dropping the special handling for the
  first iovec and restructuring the innermost loop. This also rules out
  the possibility of a zero-length temporary vec. IMHO the readability
  has improved quite a bit (YMMV :-). Hopefully without introducing new
  bugs; please review!
* Corrected computation of totalSize in case less than size has been
  read/written.
* Also set *_numBytes in case all fileVecs have been processed. Only
  relevant in case the request extends beyond the end of file.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20483 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-31 22:44:01 +00:00
Axel Dörfler
061816eefa * Fixed two bugs found by Ingo: the tempVec array bounds weren't checked when
filling them which could have written over the stack, and their iovec length
  was set for the wrong iovec, potentially clobbering any memory.
* The first tempVec was usually empty, anyway, as the wrong iovec was chosen
  to start from (usually one too early).
* The tempVec loop is now repeated until the whole fileVec is completed.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20476 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-31 09:54:56 +00:00
Ingo Weinhold
27d37d4d24 * Optional debug feature for tracking which page queue a page should be
in.
* New debugger command "find_page", which searches all page queues to
  find out, which one a page is actually in.
* Solved nasty race condition between the page scrubber and
  vm_page_allocate_page_run(): The page scrubber didn't mark the pages
  it was processing busy, so that vm_page_allocate_page_run() could claim
  them in the meantime. They would end up in the clear pages queue,
  although being assigned to a cache at the same time. This should
  finally solve bug #1056.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20474 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-30 19:48:51 +00:00
Axel Dörfler
0bfaee2899 parse_line() is now smart enough to detect quoted strings and escaped characters.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20471 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-30 13:44:46 +00:00
Axel Dörfler
3a1532ef98 In case the source cache of the current vm_cache_ref was in the process of
being merged in vm_cache_remove_consumer(), fault_find_page() tried again
with the current vm_cache_ref, but didn't realize it might have had inserted
a busy page in this cache already.
This fixes a deadlock, as this page would never get unbusy again.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20470 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-30 12:14:43 +00:00
Axel Dörfler
94d37a4b51 * map_backing_store() did not set the private mapping's cache to CACHE_TYPE_RAM.
* Some more debug helpers.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20469 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-30 09:45:50 +00:00
Axel Dörfler
673a63dc41 Added more checks regarding page movement for debugging purposes.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20468 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-30 09:01:58 +00:00
Axel Dörfler
6da6433598 * common_select() now also clears the sets for B_WOULD_BLOCK and any other error
that returns 0. Patch by Hugo Santos.
* Removed superfluous memset() of select_sync structures.
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20467 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-29 16:09:53 +00:00
Ingo Weinhold
3e414ec314 Fixed broken iteration in block_cache::RemoveUnusedBlocks(). The loop
would start with the first block in the unused blocks list, but then
continue with the blocks that share the same hash table slot, thus
freeing potentially used blocks. Could theoretically have caused
BFS to see and write incorrect meta/administrative data on certain
occasions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20459 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-28 22:53:45 +00:00
Ingo Weinhold
3f51dabd08 Another fault handler instance where we have to trick gcc4 not to
optimize our code away.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20450 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-28 15:59:51 +00:00
Ingo Weinhold
369e45856b Added TODO.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20435 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-27 13:04:50 +00:00
Axel Dörfler
6c533c4f43 Somehow, the system doesn't run that well when the scheduler skips only rarely; I'm not
yet sure what is causing this, but until I find the time to look into it (or someone else
as part of GSoC), raising the limit helps.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20427 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-26 10:28:39 +00:00
Axel Dörfler
a201ac2cf9 The kernel no longer allows anyone to rename a thread unless you're the current
owner of that thread - this fixes the kernel part of bug #1122.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20419 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-25 12:42:30 +00:00
Ingo Weinhold
6376aa3f7a * The close-on-exit bitmap vfs_new_io_context() created was a byte
short, if the FD table size wasn't a multiple of 8.
* vfs_resize_fd_table() didn't seem to know at all about the
  close-on-exit bitmap. The pointer in the io_context would point to
  free()d memory afterwards. This explains the sporadically closed
  stdin/out/err descriptors in programs started from Tracker and
  Deskbar.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20413 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-23 21:19:02 +00:00
Axel Dörfler
d349f3c941 select() is supposed to clear the sets in case of B_TIMED_OUT - found and patch
by Hugo Santos - thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20412 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-23 20:40:03 +00:00
Axel Dörfler
c0c59f5b2d Accidently unmapped the wrong pages in case of COW after the last commit...
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20408 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-23 12:36:24 +00:00
Axel Dörfler
c6a7ff7a9f * The new vm_page_mappings weren't updated correctly in many cases.
* Added a comment to vm_remove_all_page_mappings() that shows that we need to
  change the mapping spinlock into a mutex.
* Pointed out some potential problems in the code.
* Added vm_page_at_index(), vm_clear_map_activation(), and vm_test_map_activation()
  in preparation of the page scanner rewrite.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20407 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-23 11:48:37 +00:00
Ingo Weinhold
529bf4045b In a copy-on-write situation a page from a lower cache must always be
mapped fully read-only (for both kernel and userland). Previously a
kernel read access to a yet unmapped r/w accessible userland address
would cause the page from the lower cache to be mapped with write
permission for userland (on x86 also for the kernel) thus e.g.
allowing a fork()ed child process to write to the parent process'
memory.

Fixes bugs #113 and #928.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20402 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-21 19:48:38 +00:00
Ingo Weinhold
44b5d72b5a Added new functions to the debugger API:
{set,clear}_debugger_{break,watch}point(), allowing to set/clear break
and watchpoints for the calling team. When a break/watchpoint is hit,
the team enters the debugger. Handy in situations when the program in
question can't really be started in a debugger (or it would be
complicated to do so). The functions work only as long as no debugger is
installed for the team.

We clear the arch specific team and thread debug infos now, when a new
debugger is installed, thus clearing break- and watchpoints.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20396 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-20 16:20:13 +00:00
Axel Dörfler
4d7c45a7f1 Fixed PPC build (still using the older compiler, though).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20384 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-14 15:47:11 +00:00
Jérôme Duval
f5c30dd323 added checks to trick the gcc4 compiler. this way the label is kept.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20380 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-13 00:32:48 +00:00
Ingo Weinhold
e4b4574f41 Reordered somewhat unhealthy looking if-construct (first
"currentPage->state == ..." then "currentPage != NULL").


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20377 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-12 12:23:45 +00:00
Axel Dörfler
de4145dbb6 Cleanup:
* NewBlock()/FreeBlock() are now symmetrical in that the former no longer inserts
  the block into the hash table.
* delete_transaction() also no longer removes the transaction from the hash table.
* cache_transaction_sync() now uses the new hash_remove_current() function.
* minor other cleanup (like line breaks).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20374 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-11 23:17:28 +00:00
Axel Dörfler
f19d32ef8f Fixed warning.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20369 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-11 21:19:20 +00:00
Axel Dörfler
826e857cf0 Implemented hash_remove_current() which removes the current iterator position
from the hash - not yet tested.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20368 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-11 21:18:49 +00:00
Ingo Weinhold
e1555e1fdf get_cached_block(): Remove the newly allocated block from the
hashtable in case of a read error (NewBlock() also adds the block,
but FreeBlock() only frees it).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20365 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-11 13:51:18 +00:00
Axel Dörfler
6e601ee88f get_memory_map() now panics (and fails) in case it was called on unmapped memory as
suggested by Ingo; before it would just fill the physical pages with NULL pointers.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20364 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-11 13:27:42 +00:00
Ingo Weinhold
bf4604c363 Fixed incorrect loop conditions in [un]lock_memory(). If the given
start address wasn't aligned and numBytes was a multiple of the page
size, the last page was ignored. A subsequent get_memory_map() would
return NULL as physical address for that page, if it hadn't been mapped
before (that function looks generally suspicious, IMHO). E.g. reads from a
device into an unaligned buffer that hadn't been touched before would
hit that problem. Fixes bug #1075. Might also fix other reported
problems (like #1056), since this bug could have cause all kinds of weird
behavior and crashes. 


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20362 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-09 21:40:56 +00:00
Axel Dörfler
1594e83f84 * All mapped pages that are not wired (ie. locked) now have a vm_page_mapping object
that points to both, the page and the area the page is in. This will allow a page
  scanner to steal unused pages when necessary.
* The locking is currently done with a spinlock which we might want to have another
  look at one day.
* dump_page() and dump_area_struct() now dump the page mappings as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20356 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-08 14:35:26 +00:00
Ingo Weinhold
1822f5ecbc Added strtod() and localeconv() to the kernel.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20348 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-07 07:18:51 +00:00
Ingo Weinhold
cf4ccd6575 Renamed the FS interface hook read_link() to read_symlink().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20330 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-05 03:52:57 +00:00
Ingo Weinhold
12d359b85a * Removed write_link from the FS module interface. Adjusted all FS
add-ons accordingly and removed the syscall.
* Removed send_notification().
* Reimplemented notify_listener(). It used the unimplemented
  send_notification(). Now it has a chance to work. Note that
  notify_listener() is obsolete. I would already have removed it, if
  there weren't lots of FS implementations still using it (Hint!).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20329 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-05 00:46:57 +00:00
Ingo Weinhold
348be5b50b * Introduced the new static lock sVnodeCoveredByMutex to guard the
vnode::covered_by fields. Together with sMountOpLock it allows write
  access, either lock alone suffices for read access. Before
  sMountOpLock had to be acquired for read (and write) access, which
  meant that while mounting/unmounting a FS path resolution would have
  to wait. In case of the UserlandFS this would even cause a deadlock
  while mounting if the client tried to resolve the path of the device
  to be mounted (e.g. by opening it).
* Added a clarifying comment about read access to the
  fs_mount::covers_vnode/root_vnode field and removed locking in
  resolve_volume_root_to_mount_point() which was not necessary for
  explained reasons.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20308 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-03 02:42:36 +00:00
Ingo Weinhold
2f742879c8 * Changed get_vnode_name() to take a dirent* parameter instead of the
name (saves copying the name, if that has to be done anyway) and added a
  wrapper version with the old interface.
* dir_vnode_to_path() was broken for file systems that didn't support
  the get_vnode_name() hook. It resolved the mount point too early, so
  that it was searching the mount point and not the FS root dir for the
  node. It uses the get_vnode_name() function now (before resolving the
  mount point).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20305 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-02 09:34:33 +00:00
Ingo Weinhold
9481e62bdb is_vnode_removed() is now known as get_vnode_removed() and returns its
answer through a reference parameter.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20297 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-02 00:34:20 +00:00
Axel Dörfler
ab0ad5e92b Implemented printing the stack trace in vm_page_fault() for PPC as well.
Not tested, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20284 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-01 14:39:09 +00:00
Axel Dörfler
00be6a4ccb And of course, we shouldn't test newArea->cache_type before it was set...
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20283 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-01 13:58:34 +00:00
Axel Dörfler
528e40c07d Of course, we need to query the address space of the source area, not the one of the target.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20282 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-01 13:52:58 +00:00
Axel Dörfler
0c12332715 * vm_map_physical_memory() now sets the wiring/locking type of the area created
to B_FULL_LOCK.
* vm_clone_area() now respects the source area's wiring and inherits it. This
  should fix bug #1055.
* vm_cache::type is now duplicated in vm_area::cache_type - this allows looking
  it up without having to lock a vm_cache_ref; this also solves a locking bug
  in vm_unmap_pages() in this regard.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20281 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-01 13:44:55 +00:00
Axel Dörfler
5eb9da355a * The KDL commands cache/cache_ref will now also print the type of the cache.
* Made the output look a bit more like that of the other commands.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20279 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-01 13:09:41 +00:00
Travis Geiselbrecht
0098867364 this seems to solve the 'lock up on bootup on core 2' problem.
Basically, there was a pretty subtle race between the cpus in main where if the main cpu released the AP cpus and then before the AP cpus had a chance to run the boot cpu started creating the main thread (which causes smp ici messages to be created) the system would livelock, where the boot cpu waited forever for the AP cpu to acknowledge the ICI (for a TLB flush when creating the kernel stack).
Added smp_cpu_rendezvous(), used to synchronize all the cpus to a particular point, and used it a few times in main().
While i was at it i fixed another race that'll probably never happen, but what the hey. Make sure the kernel args are copied into kernel space by the main cpu before letting any other ones use it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20269 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-01 08:09:28 +00:00
Travis Geiselbrecht
8d7966617a the last smp change wasn't quite it. This time, make sure it maps the right physical page.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20268 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-01 07:49:43 +00:00
Travis Geiselbrecht
2df0aaea1d the recent vm change uncovered a long standing latent pseudo-bug where the local and ioapic memory window were mapped into kernel space via create_area(), not map_physical_memory() like it should be. create_area() used to work fine, but now it's a big more picky about mapping memory it can't get a vm_page to (like stuff outside the range of RAM).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20265 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-01 06:30:16 +00:00
Ingo Weinhold
6d3667845f Be nicer to FSs and fill in the known part of the fs_info *after* the FS
had its go. BeOS does the same.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20262 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-01 02:55:41 +00:00
Ingo Weinhold
223bba10f3 Resurrected is_vnode_removed().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20256 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-28 22:24:28 +00:00
Axel Dörfler
ca954b7816 Another work-in-progress towards having extra structures per mapping per page:
* vm_area and vm_page now have a new field "mappings" where they will store lists
  of vm_page_mapping structures. vm_page::ref_count is gone, as it's no longer
  needed (it was never updated correctly, anyway).
* vm_caches now have a type field, ie. CACHE_TYPE_RAM for anonymous areas - this
  makes the stores a bit less independent, but is quite handy in several places.
* Added new vm_map_page() and vm_unmap_pages() functions to be used whenever you
  map in or unmap pages into/from an area. They don't do much more than handling
  vm_page::wired_count correctly right now, though (ie. B_LAZY_LOCK is now working
  as expected as well).
* Moved the device fault handler to vm_map_physical_memory(); it was not really
  used as a fault handler, anyway.
* Didn't notice Ingo's changes to the I/O space region broke lock_memory(). It
  now checks the type of the area that contains the memory, and doesn't lock
  anymore if not needed which solves the problem in a platform independent way.
* Implemented lock_memory() and unlock_memory() for real: they now change the
  vm_page::wired_count member to identify pages that shouldn't be paged out.
* vm_area_for() now uses vm_area_lookup() internally.
* Fixed various potential overflow conditions with areas that reach 0xffffffff.
* Creating anonymous areas with B_FULL_LOCK no longer causes vm_soft_fault()
  to be called, instead, the pages are allocated and mapped (via vm_map_page())
  directly.
* Removed the _vm_ prefix for create_area_struct() and create_reserved_area_struct().
* Fixed a bug in vm_page_write_modified() that would not have enqueued pages that
  failed to be written to the modified queue again when needed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20251 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-28 13:24:53 +00:00
Axel Dörfler
5cd229a5a1 I accidently broke the build with some work-in-progress changes, this should fix it for now.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20249 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-28 11:04:55 +00:00
Axel Dörfler
583ed1c698 * Applied codestyle patch by Vasilis Kaoutsis (missing space between if/for and the
opening bracket) - thanks!
* Shuffled functions a bit around to separate static and exported functions.
* Some other cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20245 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-27 22:33:58 +00:00
Axel Dörfler
3eca858515 * Moved the early startup VM allocation functions from vm_page.c to vm.cpp.
* Renamed them, made everything static besides vm_allocate_early() (previous
  vm_alloc_from_kernel_args()) which now allows you to specify a different
  virtual than physical size, and therefore makes vm_alloc_virtual_from_kernel_args()
  superfluous (which isn't exported anymore, and is now called allocate_early_virtual()).
* Enabled printing a stack trace on serial output on team crash - it doesn't hurt
  for now, anyway.
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20244 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-27 19:26:40 +00:00
Ingo Weinhold
c2f0ee7a7b Don't send B_ENTRY_MOVED messages twice, if fromDirectory == toDirectory.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20232 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-26 00:57:45 +00:00
Marcus Overhagen
a090257d09 Add volatile keyword to apic memory access, cleanup, add timeout to arch_smp_send_ici.
But this still doesn't help with bug #1018...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20231 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-25 23:32:21 +00:00
Marcus Overhagen
ca21e6053e really invalidate the TLB of non-boot CPUs
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20200 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-22 19:47:28 +00:00
Jérôme Duval
301d9851fe fix change in revision 20162, the path was left out
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20186 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-20 20:27:23 +00:00
Jérôme Duval
d4d9831990 merge both commpage.h into the private header
Travis, I hope this fits your needs :)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20173 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-20 00:21:45 +00:00
François Revol
c926cb8d8a Return sensible errors instead of -1. Added some TODO comments.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20166 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-19 15:57:58 +00:00
François Revol
c8d3c6f470 Implemented get/setrlimit(RLIMIT_NOVMON). Note the kernel calls don't set errno... but they're called by user versions. Might want to split them if needed.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20165 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-19 15:48:02 +00:00
Travis Geiselbrecht
040e5e50f1 fix a kernel clobberer that showed up when running gcc. Was able to successfully build a hello world app with gcc after this.
The kernel arg logic was faulty, and wasn't using strlcpy properly (which returns the size of the src string, not the remaining size). Replaced it with a simpler, but less efficient series of strlcat()s.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20162 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-19 06:57:38 +00:00
Travis Geiselbrecht
1cbf8f4b3c initial support for a commpage, which is a chunk of memory in high kernel space with user readonly permissions.
The first use is to let the kernel decide what the preferred syscall mechanism is at boot time and copy the
appropriate user space code there. Can be used for routines the kernel can decide best how to use (memcpy, some
timing routines, etc).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20161 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-19 00:32:44 +00:00
Travis Geiselbrecht
badc7b674e yet another fix for #1018, which has at this point blossomed into a reorg of how AP cpus are initialized.
the new cpuid stuff was apparently exacerbating an existing problem where various bits of low level
cpu code (specifically get_current_cpu) weren't really initialized before being used. Changed the
order to set up a fake set of threads to point each cpu at really early in boot to make sure that at
all points in code it can get the current 'thread' and thus the current cpu.
A probably better solution would be to have dr3 point to the current cpu which would then point to the 
current thread, but that has a race condition that would require an int disable, etc.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20160 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-19 00:11:24 +00:00
Marcus Overhagen
b2562a8d64 This fixes building with TRACE enabled
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20159 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-18 21:44:29 +00:00
Travis Geiselbrecht
774565638e man, I gotta quit making stupid mistakes. this dumb cpuid commit is really screwing the pooch.
Should be another fix for #1018


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20158 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-18 20:54:02 +00:00
Travis Geiselbrecht
4bfe6b4b7f Don't reschedule at the end of every syscall. Speeds up syscalls by about 15%.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20155 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-18 04:53:15 +00:00
Travis Geiselbrecht
306a9ae49f should be a fix for #1018. The new cpu detect code was running on each cpu as they come up, storing
away cpuid info into the current cpu structure. Trouble was the code was running before the current
thread pointer was set on each cpu, so it was always looking up cpu 0's structure and saving there,
leaving the other ones uninitialized. Surprisingly this works fine on my machine, but obviously fails
on others (cpuid info would have been zeroed probably). Solution is to change the order that things
are brought up on each cpu to set the current thread pointer first. I don't really like that solution
but it'll work for now. Added a comment to the effect.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20154 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-18 04:11:43 +00:00
François Revol
158a9c384b Much simpler and safer ttyname() using B_GET_PATH_FOR_DEVICE. Also added ttyname_r for which we had a proto in the headers.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20133 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-15 14:01:40 +00:00
Travis Geiselbrecht
dfb5375d18 clean up TSS initialization.
Now two complete tss structures exist within the per-cpu structure. Instead
of having to create a seperate area per each one, initialize them in place.
Also, the old mechanism to getting all of the cpus to get initialized was 
subtly broken, but still managed to work. Now, just force all the cpus to
initialize at boot, which makes the actual swapping of esp0 somewhat simpler.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20131 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-14 06:24:59 +00:00
Axel Dörfler
4d634ea794 Prevented the somewhat broken env copying code from clobbering memory it shouldn't really touch.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20127 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-13 06:42:58 +00:00
Axel Dörfler
aa547f5fbb * mutex_lock() and recursive_lock_lock() now return a status_t and report failure.
* recursive_lock_unlock() now returns a void to mirror it's counterpart better;
  use recursive_lock_get_recursion() if you're interested in the lock depth.
* switch_sem(), and release_sem() now don't do anything anymore in kernel startup
  mode.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20099 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-07 14:07:31 +00:00
Axel Dörfler
d5d570384c The mutex was created too early, before semaphores could be used.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20098 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-07 13:50:50 +00:00
Axel Dörfler
b200275472 Flushing the translation map is done automatically on unlock.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20097 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-07 13:49:50 +00:00
Axel Dörfler
eb117b4bfd Reworked the way thread_yield() works: just setting the thread to B_LOWEST_ACTIVE_PRIORITY
for one quantum wasn't really a good idea, as this could get quite expensive for the thread
(depending on the system load, it might have taken a long time until the thread was scheduled
again, no matter what priority it was).
Also, calling thread_yield() in a loop would have taken 100% CPU time.
Now, we sort the thread into the queue as with any other thread, but we'll ignore it once.
This now guarantees an actual context switch, as well as a much fairer rescheduling policy
for threads calling that function.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20077 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-06 02:29:17 +00:00
Travis Geiselbrecht
dcdc4f4b43 pulled over some stuff from newos:
at boot, per cpu, detect the cpu, pull down all the relevant cpuid bits and
save them into the per-cpu structure. Changed most of the code scattered here
and there that reads the cpuid to use a new api, x86_check_feature, which looks
at the saved bits.
Also changed the system_info stuff to read from these bits.
While i was at it, refreshed all the bits to be current.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20072 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-05 01:46:28 +00:00
Travis Geiselbrecht
ea4ff0f689 is_computer_on() lives again as a true syscall.
Replaced the _kern_null syscall with _kern_is_computer_on.
is_computer_on_fire is a bit harder, since it returns a float from kernelland, which
at the moment isn't supported in haiku.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20069 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-04 21:08:35 +00:00
Axel Dörfler
ebabf50a02 x86_userspace_thread_exit() did not correctly setup the stack for the syscall.
I don't know why (or how) it could work before r19775, though.
This fixes the wrong return code from wait_for_thread() in most cases, and thus,
bug #1011.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20060 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-03 18:30:24 +00:00
Axel Dörfler
a83c8bbffa Moved libroot/posix/kerrno.c to kernel/lib/ where it belongs, and renamed it to kernel_errno.c.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20044 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-02 10:53:57 +00:00
Axel Dörfler
fe70b87d91 Fixed a couple of issues in our VM:
* we now always flush the TLBs after having unmapped some pages.
* vm_soft_fault() could traverse to a source cache while it was being collapsed
  by vm_cache_remove_consumer() - this is now no longer possible as the latter
  marks the cache as busy when doing so, and the former now tests this flag and
  locks the cache (via the new fault_acquire_locked_source() function).
* if fault_acquire_locked_source() fails with B_BUSY, the current cache is locked
  again, and tested again for the page - as it might have been moved upwards to it
  with the destruction of its former source.
* The cache delivering the page for vm_soft_fault() is now locked until the end;
  it can no longer go away before having actually mapped the page into the area.
* This also fixes the issue where pages would get lost as vm_soft_fault() put the
  page in the active list, no matter if its cache still existed.
* Also, we now keep a reference of to a cache in case a dummy page is inserted; this
  makes again sure that it doesn't go away during the execution of vm_soft_fault()
  (which could even add this page to the free list...).
* divided vm_soft_fault() into several smaller functions which should make it much
  more readable.
* Added a "cache_chain" KDL command that dumps the whole chain until the bottom
  when giving a pointer to a vm_cache as parameter.
* now usually call vm_cache_acquire_ref() before map_backing_store(), even though
  it shouldn't be really needed (I added it for debugging purposes).
* Some minor cleanup.
* NOTE: a major problem still persists: when removing a vm_cache, it's possible
  that some of its pages are still mapped, and there is currently no mechanism
  to get rid of these mappings! I've added TODO comments into vm_cache.c where
  appropriate.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20028 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-01 12:12:54 +00:00
Axel Dörfler
53d43e3f52 The KDL command "page" can now also look up the physical page behind a virtual address.
The "lookup" option has been removed, there is now a "-p" for a physical address, and
"-v" for a virtual address.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20016 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-30 12:03:04 +00:00
Axel Dörfler
2e27874523 * wait_for_child() now behaves correctly when waiting for children of a specific
process group. This fixes bug #996.
* As a result, the process group stuff and wait_for_child() got much simpler;
  get_death_entry() and update_wait_for_any() could go away completely.
* If a team goes away, all of its children are now "reparented" to the kernel team,
  instead of the team's parent - this follows common implementations (and POSIX if
  I understand it correctly), but not BeOS anymore. The OpenGroup Base says this
  about this topic: "If a parent process terminates without waiting for all of its
  child processes to terminate, the remaining child processes shall be assigned a
  new parent process ID corresponding to an implementation-defined system process."
* We wait too long in wait_test_4 which at least puts us on par with Linux; see
  comment in _user_setpgid().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20010 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-29 15:33:31 +00:00
Axel Dörfler
268fe0f839 * wait_for_child() now checks if the team has any children to wait for, and returns
ECHILD in case it doesn't. This fixes bug #995.
* Added a TODO item for solving bug #996.
* wait_for_child() did not release the team lock and restore interrupts in case
  the child you wanted to wait for didn't exist...
* with child > 0, wait_for_child() will now check if its really a child of yours,
  and not just in the same process group.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19993 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-28 14:31:42 +00:00
Axel Dörfler
d2dec0aafa file_descriptor::ops is now set to NULL when the file descriptor gets disconnected.
This fixes a possible crashing bug when an application with disconnected descriptors
quits.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19951 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-24 21:04:49 +00:00
Axel Dörfler
3901c6aacf * "db/ds/dw/dl" now print all isprint() characters, not only isalnum().
* Also, the output no longer has the leading "0x" to ease reading.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19906 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-22 17:51:51 +00:00
Axel Dörfler
4108d5de80 Now checks if the address space pointer is NULL before dereferencing it.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19905 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-22 16:57:47 +00:00
Axel Dörfler
7954a14f87 Add a little hack to the "dw/db/ds/dl" commands that allows you to dump the contents
of a physical memory location.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19898 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-22 14:12:11 +00:00
Axel Dörfler
6a50382249 * Mixed consumer with consumerRef to identify the cache in the consumer list;
this fixes bug #227 again (which I recently opened again accidently).
* We actually switched the last consumer's source without having acquired its
  lock! This fixes some rare random app crashes as well as potential kernel
  crash ("cache to be deleted still has consumers").
* Some more comments to explain why things are done and can be done the way they
  are done :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19878 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-20 12:49:44 +00:00
Bruno G. Albuquerque
f212f3bad2 Fix build with TRACE enabled.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19848 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-17 16:02:19 +00:00
Axel Dörfler
6f19c1db2d There was a race condition between removing the thread from the hash and putting
its death entry into the parent team's queue - we need to do this atomically.
As an effect, wait_for_thread() sometimes failed with B_BAD_THREAD_ID.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19808 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-15 12:41:08 +00:00
Axel Dörfler
e9ffbbf36c Moved locking into map_backing_store() - it now gets a vm_cache_ref instead of a vm_store,
so that this can be done safely.
It was also needed, as it would call vm_cache_release_ref() on failure which requires you
to have no vm_cache_ref locks around (as it might deadlock in this case).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19806 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-15 11:40:13 +00:00
Axel Dörfler
d8a7f74053 vm_store::fault() is now called with having the vm_cache_ref locked, so it shouldn't
be locked again here...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19805 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-15 10:24:22 +00:00
Jérôme Duval
63ac6cdcf4 fix gcc4 build
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19802 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-14 23:33:52 +00:00
Axel Dörfler
842d81bf28 vm_cache_remove_consumer() did not only access vm_cache_ref::cache without having
had the cache_ref locked, it also locked two refs in the wrong order (bottom-up);
there was even a TODO item for this...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19801 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-14 23:29:23 +00:00
Axel Dörfler
f39acd678c * Made vm_area_lookup() part of the kernel private API.
* "sc"/"where"/"bt" now prints the area where the function of the stack frame
  is located in case there is no other information (using the above function).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19800 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-14 23:26:20 +00:00
Axel Dörfler
f4972679f7 * team::args was not correctly initialized in create_team_struct()
* even worse, in case of fork(), it was never initialized.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19799 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-14 23:22:49 +00:00
Axel Dörfler
647b1f70a5 * vm_copy_on_write_area() did not always correctly divide the ref_count of the
two cache_refs - it needs to count the consumers of the lower cache to find
  its actual number of references; the upper cache could still be in use by
  someone else.
* There were several locking bugs in the VM code; since cache_ref::cache can
  change, we must not access it without having the cache_ref locked.
* As a result, map_backing_store() now requires you to have the lock of the
  store's cache_ref held.
* And therefore, some functions in vm_cache.c must no longer lock the cache_ref
  on their own, but require the caller to have it locked already.
* Added the -s option to the cache/cache_ref KDL commands: it will only print
  the requested structure, and not its counterpart (useful if accessing one
  structure results in a page fault, as was possible previously).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19796 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-14 18:41:57 +00:00
Axel Dörfler
8edddbc0cf wait_for_thread_etc() didn't care when it could no longer find the thread it was
waiting for in case it was interrupted; but that could easily lead the thread_exit()
function to access invalid memory (and thus, crash the kernel): since we could not
remove our death entry from the thread, we have to make sure the thread (which might
still run even if not in the thread hash anymore) will access our death entry as
long as it is valid. IOW we must wait for the thread to delete its exit semaphore,
even if we were interrupted before.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19790 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-13 18:37:50 +00:00
Axel Dörfler
ff718cafed * Maintain the vm_cache::virtual_size field in all cases.
* Fixed dumping the area list of a cache I broke with the previous commit.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19789 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-13 18:33:13 +00:00
Axel Dörfler
81d5ce45a8 * Merged "cache"/"cache_ref" commands, as you usually want to have all the info, anyway
(you can still use both commands, but you'll see always the same output).
* The cache_ref's area list now also prints the owner of the area.
* Added "-p" option to "cache"/"cache_ref" that will show the pages of the cache; if you
  omit it, it will now only present you a page counter.
* Nicer output for the commands above.
* Added "dl" to display memory in 64 bit values.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19787 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-13 17:24:40 +00:00
Axel Dörfler
dcadebae62 The "thread" debugger command now also prints out the thread exit waiters.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19785 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-13 17:13:50 +00:00
Axel Dörfler
b129e4cee1 Another kernel bug less:
* send_signal_etc() (among others) used team::main_thread in an unsafe way; it is
  possible for a team to be part of the team list and a group without having
  a main thread very early in its creation process.
* Replaced most occurences of team->main_thread->id with team->id since the team
  always inherits the ID of its main thread in Haiku for quite some time now.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19781 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-12 22:54:21 +00:00
Marcus Overhagen
43792b9eed propagate required settings for the remote disk from boot loader to kernel (client-ip, server-ip, server-port)
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19780 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-12 22:27:48 +00:00
Axel Dörfler
fa4858af26 Didn't notice that x86_enter_userspace() also copied the thread entry's arguments to
the userland stack in an unsafe way - moved that stuff to arch_thread_enter_userspace(), too.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19778 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-12 20:40:39 +00:00
Axel Dörfler
dc688434ed * Added the possibility to pre-commit pages for areas that can overcommit.
* This is now used for userland stack - they now always pre-commit two pages, enough
  to initialize TLS and copy the user-thread-exit stub to that area.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19776 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-12 18:51:01 +00:00
Axel Dörfler
8fc075ac5c * There was no reason to copy the "userland calls exit_thread()" stub with interrupts
turned off - accessing userland memory. Now, arch_thread_enter_userspace() does that
  job, and as a result, may also fail.
* dump_thread() now directly prints the info of the current thread when used without
  argument (rather than iterating the thread list to look for the current thread).
* If arch_thread_init_tls() fails upon thread creation, the function will now return
  an error.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19775 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-12 18:26:32 +00:00
Marcus Overhagen
f5fa54f798 Improved error reporting when a failure to find/mount the root device occurs.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19774 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-12 18:09:15 +00:00
Axel Dörfler
7039ae3f3d Fixed warning.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19773 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-12 18:03:21 +00:00
Axel Dörfler
d1b0be94b0 * Private and temporary vm_caches now maintain their new virtual_base field, which allows
them to commit substantially less memory (we we're committing about 40 MB (!) too much
  after a complete system boot). This means you'll run out of memory less likely now.
* fill_area_info() no longer filters out kernel protection flags - we may want to keep
  filtering them when called from userland, though, dunno.
* Added new debugger command "avail" which shows how much memory has been committed, and
  how much is regarded as free space.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19771 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-12 15:07:18 +00:00
Axel Dörfler
7ed5e61cdb arch_thread_init_tls() now accesses user memory safely, and therefore could now
fail.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19768 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-11 18:21:35 +00:00
Axel Dörfler
cdcb059571 * Renamed get_team_death_entry() to team_get_death_entry() and make it available
to other kernel components.
* wait_for_thread_etc() will now search the team's death entries in case the
  thread is already gone; also resume_thread() is now done later, and its return
  code will no longer matter (as we already have our death entry, no matter if
  the thread is gone now or not).
* The fibo_load_image test now works as expected (only tested with low numbers
  yet, though - the mean testing comes later (first comes functionality) :-))


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19758 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-09 23:58:59 +00:00
Axel Dörfler
ddcd53aaf0 * Instead of choosing the next thread if we skip one, we now choose the first thread
with a lower priority than the current one.
* Further reduced the probability to skip a thread to roughly 4%, that makes around
  13 skips per second, and about 40 msecs spend in lower priority threads per second
  (with a 3 msec quantum). Might still be too much, but we'll see.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19719 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-06 12:50:01 +00:00
Marcus Overhagen
6c3245f6a7 fixed error return in _Scan() function. now only returns B_OK when a device was found.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19716 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-06 01:04:09 +00:00
Axel Dörfler
9640130c40 Removed the R5 icon from the kernel resources - it can only be compiled for Haiku.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19714 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-05 20:16:48 +00:00
Axel Dörfler
92870c3b39 We always handled signals as if their SA_RESTART flag was set - but that's not
the default case.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19711 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-05 19:27:48 +00:00
Axel Dörfler
4621a82e74 Our scheduler skipped over threads in about 30% of all cases - that's a bit much; it's
not a penalty to be the first thread in the run queue...
I've reduced it to about 12.5%, but that might still be too much.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19710 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-05 19:01:09 +00:00
Axel Dörfler
9a4b4c617b * Fixed warning.
* Now using the new %f flag to print the level of support.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19584 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-12-21 12:12:50 +00:00
Axel Dörfler
dedf1bccfe Since we're using floating point values at several places in the kernel, I added
a very simplistic floating point output routine to snprintf() and friends, for
your convenience.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19583 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-12-21 12:05:16 +00:00
Axel Dörfler
b5428267c7 This should fix the most often found kernel crash (on bootup):
* vm_soft_fault() did not take into account that a cache's source can change while
  traversing a cache chain.
* Now, we grab a reference to every cache we get before locking it, and
* no longer get the cache's source without having the cache locked.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19571 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-12-20 12:34:21 +00:00
Axel Dörfler
eb445177f9 * When a vm_cache is merged with another one, we now remove the consumer; that allows
for an extra check in vm_cache_release_ref() as the cache shouldn't have any areas
  or consumers at this point.
* Fixed a locking problem in vm_cache_remove_consumer(): the cache was acquired after
  its lock was gone, so someone else might have released in the mean time.
* if the cache's source is to be replaced, we now no longer release its lock after
  having merged it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19570 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-12-20 12:30:07 +00:00
Travis Geiselbrecht
02c92f8256 change the 'iospace' debug to use a more reasonable number of columns
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19563 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-12-19 03:27:50 +00:00
Axel Dörfler
da758f9fce * team::args is now correctly filled in.
* the member will now also be shown when dumping a team.
* minor cleanup: moved fill_team_info() into the private functions part of the file.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19551 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-12-18 12:56:27 +00:00
Travis Geiselbrecht
c4546ea038 A fix for the double-fault on bootup:
-Turns out the area removal routine had a massive race condition inside
vm_put_area(). Basically the area was removed from the address space's
area list before the pages were unmapped, so the vm could (and would)
recycle the space before the pages were finally unmapped.

It was completely reproducable on my machine during initialization of a bunch
of storage drivers that were bringing the locked_pool module into and out of
existence, which caused a thread to be spawned and stopped in rapid sucession.
On a dual processor machine, it was possible for the new thread to be started
up while the old one was still shutting down, and the kernel stack of the new
one would get wiped out.

Note, there still is a page ref counting problem with this area removal code.
It doesn't decrement the ref count of the page as it unmaps it. Will have to 
figure that out.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19549 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-12-18 09:38:00 +00:00
Travis Geiselbrecht
9bc7a58b1d Fixes a nit:
put a spinlock around the serial debug routines to keep multiple
cpus from interleaving their output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19548 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-12-18 07:23:39 +00:00
Travis Geiselbrecht
c3a89b90d3 fix the 'cache_ref' and 'cache' kdl commands
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19546 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-12-18 04:29:39 +00:00
Jérôme Duval
c20e9eefcd added a jam rule AddDriverRegistrationToHaikuImage to add device mappings on the image
commented the insertion of the attribute name in patterns in the case of a string attribute
notify_probe_by_file chooses a module based on a bus specific suffix
dm_register_child_device has a parameter to optionally check the support for the node
added scanning of bus devices after the boot filesystem is mounted
fixed dm_rescan, locking was misbehaving
fixed SYSTEM_DRIVER_REGISTRATION definition
added B_DRIVER_MAPPING attributes for PCI and ACPI devices:
  %vendor%_%device% for PCI, hid_%hid% and type_%type% for ACPI
moved acpi_device_module_info definition to public ACPI.h


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19394 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-11-29 19:09:45 +00:00
Stephan Aßmus
1f1316fc68 My first commit to the kernel.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19325 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-11-19 00:30:18 +00:00
Jérôme Duval
01b06fcc52 commented raw type handling, as it doesn't work for now
added a user friendly mode for listdev: it works for PCI


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19262 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-11-12 17:22:29 +00:00
Jérôme Duval
bef4e1fc77 * each device manager node has now an autogenerated identifier
* added a generic syscall for device_manager
it enables to iterate the device manager tree from userland
* the listdev tool is now using it: it's still incomplete as it only dumps nodes and attributes


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19260 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-11-12 15:28:09 +00:00
Jérôme Duval
2bc2898a84 fix warning
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19251 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-11-10 20:26:54 +00:00
Jérôme Duval
c74d27255b avoid crashing at the end of the list
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19217 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-11-07 00:51:33 +00:00
Axel Dörfler
0ad660a168 Remap all preloaded executables read-only and executable.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19180 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-11-02 20:38:30 +00:00
Axel Dörfler
095ee89840 Fixed warning with debug info turned on.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19122 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-10-25 15:29:41 +00:00
Axel Dörfler
d12497173a Fixed PPC kernel build (and a warning).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19058 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-10-13 11:35:28 +00:00
Axel Dörfler
6e7dc54655 Fixed GCC 4 warnings.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19057 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-10-13 11:23:34 +00:00
Axel Dörfler
78d0219799 Fixed GCC 4 warning.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19056 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-10-13 10:49:08 +00:00
Axel Dörfler
4e4c58037e Implemented collapsing forked vm_cache object chains when they become unused.
This fixes bug #227 by closing that memory and semaphore leak.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19041 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-10-10 22:47:00 +00:00
Axel Dörfler
bcf2f8133b * Fixed a big memory leak: vm_delete_areas() did not put the reference of the
address space of reserved areas - IOW address spaces were never freed upon
  team exit.
* dump_cache() now prints a list of the cache's consumers.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19040 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-10-10 22:42:12 +00:00
Axel Dörfler
45894e1088 Minor cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19039 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-10-10 22:39:57 +00:00
Axel Dörfler
a7181e951d Accidently turned on printing stack traces with the last commit.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19037 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-10-10 17:27:03 +00:00
Axel Dörfler
0b8e0bfc08 Some cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19036 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-10-10 17:25:38 +00:00
Axel Dörfler
d593e74a27 First steps towards being able of collapse vm_cache objects after forking:
* a vm_cache now maintains a list of its "consumer" caches.
* introduced to new functions that add/remove consumer to a cache (instead
  of only maintaining the vm_cache::source field).
* fixed the incorrect reference counting when doing copy-on-write; we kept
  one ref too many of the lower cache.
* minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19035 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-10-10 17:16:06 +00:00
Axel Dörfler
02cc779b7d Moved datastore implementation into net_buffer.cpp - there is no reason to clobber the kernel with it.
This also fixes the issue of exporting a C++ API from the kernel.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18974 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-09-28 18:27:30 +00:00
Axel Dörfler
5af206180e Removed executable property.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18973 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-09-28 18:09:27 +00:00
Marcus Overhagen
83bf699b3f some build fixes for pxe_ia32 platform
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18966 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-09-28 12:52:20 +00:00
Marcus Overhagen
7c3aba03bc git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18961 a95241bf-73f2-0310-859d-f6bbb57e9c96 2006-09-28 12:03:26 +00:00
Marcus Overhagen
47e8242b26 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18960 a95241bf-73f2-0310-859d-f6bbb57e9c96 2006-09-28 12:02:58 +00:00
Jérôme Duval
1ba8377d45 releases the team lock even when group is NULL
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18947 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-09-27 08:30:15 +00:00
Axel Dörfler
d9766fe30b * Changed team_get_process_group_locked() to have a session parameter instead
of a team to avoid confusion. It now also accepts a NULL session pointer in
  which case the actual group's session doesn't matter.
* Fixed the race condition in send_signal_etc() that could allow accessing an
  invalid team pointer.
* Jerome's earlier change already fixed bug #841, and this also fixed bug #855.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18941 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-09-26 12:51:59 +00:00
Jérôme Duval
0de38aa00b added needed symbols for gcc4 linking
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18910 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-09-23 14:01:49 +00:00
Niels Sascha Reedijk
5fe9705942 Fix the fix
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18899 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-09-21 08:21:55 +00:00
Niels Sascha Reedijk
1a2f476148 Build broke in r18896. Fix.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18898 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-09-21 06:57:22 +00:00
Andrew Galante
b425ce77ad A helper datastructure for network buffers. Defines a fixed-size region of same-size data blocks, and maintains a reference count for each
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18896 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-09-21 02:40:20 +00:00
Jérôme Duval
65afc3a011 also dump group and session ids
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18887 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-09-19 09:40:09 +00:00
Jérôme Duval
46a7b50c3b try to better handle signal for teams
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18885 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-09-18 22:51:07 +00:00
Marcus Overhagen
20e1d3e5e2 added _Unwind_* to make the gcc 4 linker happy, but I'm not sure if this is the correct way.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18870 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-09-17 00:05:21 +00:00
Marcus Overhagen
82029bdae8 added missing nothrow parameter
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18868 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-09-16 23:25:56 +00:00
Marcus Overhagen
a07acab41b fixed assembly code to compile with gcc 4.0.3. the original code was invalid, as there is no mov instruction to
move a 16 bit segment register into 32 bit memory location, and movzx (called movzwl within gcc) doesn't work with 
segement registers.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18864 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-09-16 20:40:19 +00:00
Marcus Overhagen
6639eae245 prevent possible crash
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18863 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-09-16 19:58:41 +00:00
Axel Dörfler
5bab2844c1 This fixes the crashing bug #849. Unfortunately, it still crashes, just at a different location.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18815 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-09-12 00:22:10 +00:00
Marcus Overhagen
a6e8772d9f fix debug output
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18807 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-09-11 16:37:02 +00:00
Jérôme Duval
4c3702d42a moved rescan call to vfs_mount_boot_file_system() as suggested by axeld :)
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18738 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-09-04 13:10:08 +00:00
Jérôme Duval
d564275ba7 added disk systems rescan to DiskDeviceManager, and called it in the post init phase
the next step would be to rescan the partition tree with a job to recognize unrecognized partitions (asynchronously ?)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18737 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-09-04 12:37:56 +00:00
Axel Dörfler
9b906ccf04 * You can now create the block cache in read-only mode (using an additional
parameter during construction).
* Doing so will now result in a kernel panic whenever your file system tries to
  write to a block.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18719 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-30 23:18:31 +00:00
Axel Dörfler
793f542244 Added a comment about the outcome of a potential problem.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18717 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-30 23:12:31 +00:00
Axel Dörfler
c40fe37f0b * Reverted the changes r17693 made to vfs_get_vnode_cache(); instead, vm_create_vnode_cache()
will now grab a reference to the vnode as well if successful. This way, vfs_get_vnode_cache()
  now actually works how it should: it will now always grab a reference to the cache and
  its underlying vnode. This removes an extra reference to the vnode (and vm_cache) that
  got ignored before and prevented volumes to be unmounted (or file caches to be removed).
  Thanks to Korli for pointing this out.
* file_cache_create() is now aware of that extra vnode reference and releases it; unmounting
  volumes is now working again as it should.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18716 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-30 23:09:04 +00:00
Axel Dörfler
96d67014ff Minor cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18715 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-30 23:00:58 +00:00
Axel Dörfler
190aa14f19 * Use user_strlcpy() instead of this scary combination of strnlen() and user_memcpy().
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18714 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-30 22:39:20 +00:00
Axel Dörfler
022567d3a0 Dumping semaphore info in the kernel debugger will now print the whole queue
of waiting threads by ID (instead of just the queue head and tail pointers).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18688 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-29 11:05:22 +00:00
Axel Dörfler
be0e738496 * send_signal_etc() now handles a pid_t of -1 specially, but not yet really correct
(that was part of the problem of bug #702).
* Fixed send_signal_etc() when you called it with a pid_t of zero: the signals should
  go to all teams in the calling team's group, not only to the team (for -1, we do
  the same for now).
* Made team_get_process_group_locked() public, and rewrote send_signal_etc() to use
  it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18684 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-29 01:41:16 +00:00
Axel Dörfler
567f38888f kill_thread() and friends are supposed to check the passed in thread_id or else
some signals could go to some group when a negative value was passed in.
This actually fixes bug #702 where SoundPlay obviously does a kill_thread(-1)
at the end (which accidently killed all userspace applications, including the
input_server, app_server, ...).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18683 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-29 01:36:54 +00:00
Jérôme Duval
4e93a7f238 fixed some warnings
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18659 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-28 10:20:45 +00:00
Jérôme Duval
56e00b3afe tzoffset is in seconds
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18651 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-27 19:03:50 +00:00
Axel Dörfler
f8b41f8219 Moved functions around, so that the static private functions are at the top.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18623 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-24 23:41:54 +00:00
Axel Dörfler
6961cdf6f2 Process groups are no longer searched via their team/session, but by using a separate
hash. This also allows them to stay valid after the group leader died when there are
other teams left in it. This closes bug #1.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18622 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-24 22:58:48 +00:00
Axel Dörfler
3e975f9210 Minor cleanup; renamed some global static variables to match our style guide.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18621 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-24 22:29:54 +00:00
Jérôme Duval
355efe3ec1 improve debug command vnode_cache: it now accepts a device arg
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18618 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-24 20:54:24 +00:00
Axel Dörfler
c33ac538c4 Semaphore could get interrupted by a pending signal, even if that signal was blocked.
This fixes the failure of the fork test 12-1.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18546 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-21 12:02:18 +00:00
Axel Dörfler
26a9fcd6ab * set_alarm() now correctly returns the time left for the currently active
alarm, or 0 if there isn't any.
* setitimer() now also sets the previous timer values correctly, so that
  alarm() and ualarm() now return the correct values as well - this fixes
  the test fork_9-1 failing at alarm().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18545 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-20 22:44:53 +00:00
Axel Dörfler
505347b0b2 Threads are now removed from the hashtable earlier, so that a kill() following
a waitpid() can no longer succeed; this fixes the occasional fork 3-1 test failures.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18544 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-20 21:34:25 +00:00
Axel Dörfler
2b6a368811 wait_for_child() could eventually hang until another team exited (or forever if
it waited for a specific child), as B_RELEASE_ALL opened up a race condition between
looking for an existing death entry, and waiting for the dead children semaphore.
Now we're counting all waiting threads for teams and groups separately.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18543 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-20 21:27:12 +00:00
Stefano Ceccherini
c941d45cd5 oldSet shouldn't be changed in case of error. Thanks axel for noticing
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18533 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-18 09:37:32 +00:00
Stefano Ceccherini
0ce93ee730 the signal block mask is inherited by the child process on fork()
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18532 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-18 08:26:37 +00:00
Stefano Ceccherini
a5a36fe421 the second parameter of sigprocmask() can be NULL
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18531 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-18 08:00:07 +00:00
Axel Dörfler
79dd3d935a * The parent/group dead semaphores are now released a bit earlier to make
wait_for_child() hanging less probable - there is a general problem with
  this code, though, as we need to have a dedicated free counter for the
  semaphore to remove all race conditions.
* Also, test fork_3-1 still sometimes fails because the thread is still
  available to the public for a short time, even after its death entry
  has been collected.
* Added a TODO in the code for these issues.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18529 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-17 21:45:37 +00:00
Axel Dörfler
73a56f1bac * wait_for_child() (the backend to waitpid()) did not work correctly in case you
wanted to wait for a specific child; it always assumed you had specified WNOHANG.
  This fixes the bug the fork_3-1 and fork_4-1 test applications reported. 3-1 still
  sometimes fails, but that's a different problem (to be solved later).
* Also, it could return B_BAD_THREAD_ID instead of the expected ECHILD (for waitpid()).
* There was a race condition between testing for a thread, and checking its death
  entry.
* wait_for_child() can now be interrupted in case it has to wait.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18528 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-17 21:40:55 +00:00
Jérôme Duval
44d5675324 KernelAddon and KernelStaticLibrary don't include kernel, kernel arch, boot platform headers anymore.
Fixed the build of most of targets using these rules. Though the build can be still broken, feel free to fix.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18521 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-17 12:18:11 +00:00
Axel Dörfler
01b2099116 Added __eieio() function to let etherpci build on PPC, too.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18489 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-11 19:47:00 +00:00
Jérôme Duval
6a6c43798f have ring_buffer built on non-haiku platforms
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18391 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-04 19:20:01 +00:00
Axel Dörfler
b526381437 Removed unused header as pointed out by Korli.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18384 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-03 22:24:03 +00:00
Oliver Tappe
b66ae2c9c8 - moved dumpBlock() into debug.c, renamed it to dump_block() and added it
to kernel-exports.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18268 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-07-25 19:46:36 +00:00
Axel Dörfler
3505a2a792 Moved gdb.h header file into debug directory, no other component needs to access it.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17962 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-06-29 16:04:24 +00:00
Axel Dörfler
13e6b02018 * Removed some unused headers.
* Removed unused pools implementation.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17961 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-06-29 15:24:40 +00:00
Axel Dörfler
4e26bc08b8 user_copy_strings_array() no longer puts 2k on the stack, but allocates a 16k
buffer to allow safe access of the user provided string - maybe we should
introduce a user_strdup() instead.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17960 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-06-29 15:23:34 +00:00
Axel Dörfler
89ae57ba77 Removed sysctl(), there is no need for this BSD-ish call.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17954 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-06-29 09:37:06 +00:00
Axel Dörfler
9150d65c83 Removed some unused old networking stuff, cleaned syscalls.c.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17946 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-06-28 14:54:58 +00:00
Axel Dörfler
f62d3b77aa Added a list_get_last_item() call - one day we should make most of them inline.
Or use the C++ list implementation where possible.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17901 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-06-21 16:13:34 +00:00
Axel Dörfler
0ba0370464 Use B_MAX_SYMLINKS instead of SYMLINKS_MAX (which also fixes the build, btw).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17900 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-06-21 15:44:46 +00:00
Axel Dörfler
cce6f8d05f * Changed the kernel build rules, so that the executables can have resources
files, too.
* Added a temporary icon for the kernel until Stephan comes up with a better
  one (hint hint!) :-))
* This even fixes bug #648.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17825 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-06-13 16:08:55 +00:00
Axel Dörfler
d51ce54011 * Added the opportunity to add temporary debug interrupt handlers for
arch dependent code (they will be removed as soon as someone else
  asks for these interrupt lines).
* Added an interrupt driven keyboard handler to the kernel that uses
  this technique. As a result, you can now press F12 to enter the kernel
  debugger before the input_server has been started, and Control-Alt-Delete
  should reboot the system (actually I did not test the latter yet).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17806 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-06-12 22:24:53 +00:00
Axel Dörfler
d367028c04 Fixed warning.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17801 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-06-12 21:53:00 +00:00
Axel Dörfler
8265e1210c Implemented mandatory file locking, BeOS style. BNode::Lock() and BNode::Unlock()
are now working as expected.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17697 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-06-02 14:16:13 +00:00
Axel Dörfler
acac7c6834 _vm_map_file() did in fact not work correctly, but the main problem was
vfs_get_vnode_cache() which did not acquire an extra reference to the
cache_ref when the cache had to be created.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17693 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-06-01 18:21:21 +00:00
Axel Dörfler
a9fa017d82 map_backing_store() did not acquire a cache ref in case it created a private
mapping, but it connected the vm_cache objects, so if it failed later, and
thus called vm_cache_release_ref() the object could have been freed accidently.
Most uses of map_backing_store() explicetly acquired a cache_ref *after* the
call was successful, but _vm_map_file() did not do this.
_vm_map_file() might still not work correctly, though, need to have a closer
look at it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17692 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-06-01 18:14:59 +00:00
François Revol
84aae13f6d Fix null deref; include \0 when copying paths
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17662 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-31 00:01:01 +00:00
François Revol
8be1739f45 - change the check_pending_repeats from a thread to a kernel_daemon, one less.
- add loading of kernel debugger/ modules
- add a kgets() exported func for use by nasty modules =)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17657 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-30 19:54:37 +00:00
François Revol
b3baad129f - reordered ioctls cases to match Driver.h
- implemented B_GET_PATH_FOR_DEVICE
- reject 3 legacy ioctls from R5 (*FIXED_DRIVER, NEXT_OPEN)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17656 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-30 19:52:32 +00:00
Axel Dörfler
974533ab5a * Fixed a big race condition that could leave threads waiting infinitely and
let them eat death stack entries: after setting the next thread state to
  THREAD_STATE_FREE_ON_RESCHED, interrupts were enabled again, which could
  cause the thread to be rescheduled before having called put_death_stack().
  This fixes bug #434.
* Note that the above change pretty much reverts revision 7865 that was supposed
  to fix interrupt problem on thread exit (patch by Jack Burton almost 2 years
  ago, that's how long this problem existed!).
* Made get_death_stack() and put_death_stack() symmetrical in that they don't
  change interrupts. Also pulled out rescheduling from put_death_stack[_and_reschedule]()
  and put it back into thread_exit2().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17652 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-30 14:17:09 +00:00
Axel Dörfler
c8882988b7 The kernel's struct team now has a field to remember where the arguments of a
running team to be able to fill in the team_info::args field. Currently, only
the path is stored, there, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17646 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-30 00:21:22 +00:00
Axel Dörfler
f0ed203a59 * B_GET_GEOMETRY is now intercepted and corrected for partitions - this fixes bug
#603.
* Moved devfs_get_partition_info() into the devfs_ioctl() hook.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17622 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-28 15:30:51 +00:00
Axel Dörfler
20914efdcf Made _user_open_entry_ref() a bit more relaxed and return B_BAD_VALUE on some
obvious errors.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17586 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-25 13:03:13 +00:00
Axel Dörfler
69c86c993d A stupid typo that caused Haiku to crash when there was no CPU module.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17581 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-24 23:30:30 +00:00
Axel Dörfler
1283fc6e42 No longer call init_mtrrs() if there are no MTRRs, also made generic_init_mtrrs()
no longer try to access any MSRs when there are no MTRRs. Got it? :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17574 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-24 10:18:49 +00:00
Axel Dörfler
517dfdf48b The cache did not correctly retrieve the file map when the file was fragmented
into more than MAX_FILE_IO_VECS pieces. This could have very weird consequences
like overwriting data outside the file (but on that same partition only).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17536 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-22 16:36:20 +00:00
Jérôme Duval
f506eea587 NULL signal should be handled as others, except it has no effect
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17528 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-22 10:30:32 +00:00
Stephan Aßmus
bd5ed534cf a fix to the file cache (done by Axel), that prevents a crash when
reading the file map of certain files (hope I got that more or less
right)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17525 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-22 09:59:07 +00:00
Axel Dörfler
4b25b1b99a common_lock_node() now pretends to be successful - this should fix Vision not being
able to store its settings for now (bug #589).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17505 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-19 08:54:50 +00:00
Axel Dörfler
01fdd314e5 Some GCC 4.1.0 related build fixes (under Linux/PPC).
Doesn't build yet, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17500 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-17 20:54:12 +00:00
Jérôme Duval
0f22d7cfa8 seems we reversed the timezone offset when setting the hw clock
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17440 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-13 15:41:33 +00:00
Axel Dörfler
2bbc6df8dc * The kernel now remembers the signal that killed a thread (if it was killed).
* As suggested by Korli, the signal is now encoded in the "reason" field of
  wait_for_child().
* waitpid() now sets the status passed in so that the signal can be read out
  (but it still doesn't do it's full job).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17338 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-05 15:33:34 +00:00
Axel Dörfler
3cb039fffa When you try to mount a file image, BFS now only sees the normalized path instead
of the one supplied to fs_mount() (but not the /dev/disk/virtual/... entry, as that
wouldn't be that clear to the user).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17335 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-05 11:17:08 +00:00
Axel Dörfler
65bd831cbb * KDiskDeviceManager::_ScanPartition() can now run synchronously (and execute the
scan job in the calling thread).
* KDiskDeviceManager::InitialDeviceScan() now runs synchronously, so that
  get_boot_partitions() doesn't need to do this ugly wait hack.
* KDiskDeviceManager::CreateFileDevice() can now run synchronously as well, which
  fixes a deadlock in fs_mount() - note, mounting file devices still doesn't work,
  though as Haiku's BFS doesn't allow this right now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17334 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-05 10:54:10 +00:00
Axel Dörfler
b02b72c448 Minor cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17333 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-05 10:44:07 +00:00
Axel Dörfler
dde52de872 * _NewReadLockInfo() can no longer crash in case the allocation failed.
* _ReadLock() will now fail with B_NO_MEMORY in case the ReadLockInfo couldn't
  be created.
* Note, due to a design bug, we cannot guarantee that a previous read lock
  can be reestablished after releasing a write lock in case of low memory.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17332 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-05 10:10:05 +00:00
Axel Dörfler
573c4336a3 Implemented quite a hack to solve the lockless get_memory_map() problem (bug #349):
when called with interrupts turned off, get_memory_map() will now call the new
vm_translation_map_ops::query_interrupt() call.
Under PPC, this is trivial (at least right now), but on x86 we need to make sure
we have access to the page table entry, ie. we need to create an area that points
to its own page table entry, so that we can map in the page table entry containing
the address we're looking for. It's not really nice, feel free to come up with
a cleaner solution :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17280 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-30 17:45:33 +00:00
Axel Dörfler
77a08c68e8 Changed the way handlers for edge triggered interrupt are called: now, we
always call all handlers in this case, but we still try to return the correct
return code (ie. B_HANDLED_INTERRUPT and B_INVOKE_SCHEDULER).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17278 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-30 13:56:21 +00:00
Axel Dörfler
f7a446f46f Oops, actually forgot to press "save" in the editor to include the real thing...
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17277 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-30 13:44:24 +00:00
Axel Dörfler
99df69077c For level triggered interrupts, we now acknowledge the interrupt after having called
the interrupt handlers, not before (like we do for edge triggered ones).
This should prevent hardware from issuing a second interrupt when the software driver
is still busy handling the first.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17276 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-30 13:43:05 +00:00
Axel Dörfler
5886ae3213 Finally (!) fixed that stupid bug that prevented at least some Pentium-M laptops to
work correctly when on power supply (ie. when running at full speed). Turns out we
misdetected a spurious interrupt on line 15 - we now ignore them completely which
seems to fix that problem.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17275 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-30 13:35:53 +00:00
Michael Lotz
17fee3eab7 Removed the extra info struct in the cpu_ent union and made said union a struct instead. Same as r1137 in NewOS.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17273 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-29 22:38:19 +00:00
Michael Lotz
2a03240eb1 Reverted my last change as it turned out that the lazy FPU state handling was not SMP safe afterall and the performance gain is questionable. Maybe it'll be implemented correctly in the future. Sorry for any inconvenience this may have cost.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17272 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-29 22:10:04 +00:00
Michael Lotz
7eee76e65a Implemented lazy FPU state save/restore. In the end mostly ported from NewOS. SMP safe.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17251 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-27 22:02:48 +00:00
Axel Dörfler
11add5a5d7 First baby step towards a lockless get_memory_map(): vm_get_current_user_address_space()
no longer needs to lock address space hash table - that also makes the lookup much
faster, too (and a direct pointer is used instead of a hash lookup).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17246 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-27 17:46:19 +00:00
Axel Dörfler
4827dbe47a Fixed a bug in the VFS that could cause BFS to corrupt an inode:
dir_remove() did not normalize the path, and thus, could forward a "." as
name for the removed directory - which BFS didn't catch because it assumed
our VFS would work correctly...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17165 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-18 17:40:27 +00:00
Axel Dörfler
a88c592fb3 Instead of ending up in an endless loop, fs_sync() will now bail out in
case get_vnode() fails.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17162 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-18 14:50:36 +00:00
Axel Dörfler
fde87a1094 Instead of waiting forever, get_vnode() will now fail after 3 seconds if the
vnode is not becoming unbusy (right now it even panics, but that can be removed
later on).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17161 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-18 13:55:47 +00:00
Axel Dörfler
80fda87e9c find_thread() now returns B_NAME_NOT_FOUND when it doesn't find the thread
as stated in the BeBook - this fixes bug #458 as Tracker directly compared
with that error code.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17144 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-16 17:53:10 +00:00
Axel Dörfler
b2536cb5d6 Fixed bug #483:
* vfs_get_fs_node_from_path() now also work for absolute paths again (but
  still for relative ones from the volume root) - it just tests if the
  mount IDs fit, so it only returns successful if the path really is on
  the desired mount.
* the Disk Device Manager publish functions now call devfs_publish_*()
  correctly (by omitting the "/dev/" mount point).
* devfs_publish_partition() now accepts absolute device paths but relative
  partition paths.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17138 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-16 11:44:54 +00:00
Michael Lotz
b026647574 Changed the temporary buffer to be static to avoid using that much stack. Replaced wrong maximum buffer length (oops).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17137 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-16 10:56:00 +00:00
Michael Lotz
1df23ecc52 Should finally fix the eaten up messages. We obviously must not use the output buffer to write the repeat count as the output buffer already contains the new message...
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17131 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-14 12:38:31 +00:00
Axel Dörfler
9a11448fbd vfs_get_fs_node_from_path() didn't work correctly and ignored the mount_id
(ie. it only worked for absolute paths, but it shouldn't work for those at
all).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17127 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-13 18:06:30 +00:00
Axel Dörfler
97e069713b Added a "reenter" parameter to the {read|write}_pages() functions to give file
systems a chance to know if they have locked already.
This fixes a locking problem in BFS where one thread tried to acquire two read
locks (where someone else trying to acquire a write lock would have caused a
dead lock).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17108 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-12 13:34:04 +00:00
Michael Lotz
2f5143505b Another try at removing the "Last message repeated 1 times.", this time with locking.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17099 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-11 21:11:50 +00:00
Michael Lotz
6ac6b512a0 Reverted my last change as it causes a segfault with syslog output enabled.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17094 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-11 19:40:49 +00:00
Axel Dörfler
8645479b36 * cache_io() could insert a second page at the same position in the vm_cache
since it unlocked the cache while waiting on a busy page. Now, we're filling
  the pending request before unlocking the cache.
* Fixed the deadlock I mentioned in the last commit: if a page fault happens
  at the same time we're trying to read/write from/to a page, we no longer
  fight for the BFS inode lock, but eventually doing the job twice if needed.
  Will need to go over the "write modified" functions to make sure they are
  behaving as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17091 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-11 18:48:04 +00:00
Axel Dörfler
be891a5e5d No longer counts "\n" as repeated string - this seems to fix at least the cases
where I noticed missing debug output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17090 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-11 18:40:46 +00:00
Michael Lotz
d7faea3f20 Replaced "Last message repeated 1 times." with just reprinting the message (requested by Jerome Duval).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17060 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-10 21:28:43 +00:00
Axel Dörfler
675c19c9cf * fs_sync() and free_vnode() now use the file system's fsync() hook to write back
changes made to a file instead of directly using vm_cache_write_modified() -
  besides making the file system more independent from the file cache, this also
  works around a possible dead lock (that is to be fixed in a later commit).
* fs_sync() no longer uses vnodes from the mount's vnode list directly to write
  back the changes made to them, but gets them via ID instead - this makes sure
  the vnode is in a valid state and fixes a race condition with free_vnode().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17059 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-10 21:22:24 +00:00
Michael Lotz
f51fb4696c Corrected the repeat checks (did not compare the right buffers) and added a length argument to debug_puts() to safe the strlen in the syslog case. Also removed some leftover.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16991 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-03 20:48:30 +00:00
Michael Lotz
3647d70ded Replaced the hash based approach to repeat detection with the probably more efficient strncmp.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16970 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-02 16:45:04 +00:00
Michael Lotz
3352a462a7 Implemented the "Last message repeated x times." thing in the kernel (hash based).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16968 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-02 16:23:47 +00:00
Axel Dörfler
af3e5cd947 Renamed our runtime loader from rld.so to runtime_loader, and moved it into beos/system/.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16936 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-30 18:08:51 +00:00
Axel Dörfler
2a62d0d6c5 Added a second pass to the boot device retrieval in case nothing has been found.
Right now, the size of the device is ignored in the second pass. Maybe this helps
with bug #357.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16917 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-29 00:16:57 +00:00
Axel Dörfler
606e0d364e * Factored out the vnode disconnection code from fs_unmount() to a separate
function, and added a vfs_disconnect_vnode() for other kernel components.
* devfs_unpublish_device() can now optionally make use of this call.
* Fixed the type check of devfs' unpublish_node().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16907 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-28 01:13:12 +00:00
Axel Dörfler
065aa7f66c Added a basic unpublishing function for drivers, not yet tested, though (and even
though it looks so simple, I see no reason why it shouldn't work 8-)).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16906 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-28 00:13:44 +00:00
Axel Dörfler
fabe8c62ff The kernel boot code now supports the unknown bus/device method to identify the
boot volume. The other (better) methods are now disabled in the boot loader.
This fixes bug #241.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16895 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-27 17:01:10 +00:00
Axel Dörfler
d140fed68f Turned off some debug output, the device tree is no longer dumped (was a partial
tree only, anyway, as it was dumped before the recognition of any devices).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16893 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-27 15:14:30 +00:00
Axel Dörfler
c918a987a0 * Removed my old doubly linked list implementation, and stay with Ingo's.
* Adapt other sources where needed (the boot loader's RootFileSystem still
  used the old implementation).
* Implemented RootFileSystem::Rewind().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16889 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-27 10:27:05 +00:00
Axel Dörfler
7d2fafcac5 Forgot even more debug output...
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16882 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-26 18:45:54 +00:00
Axel Dörfler
61106f7e86 Forgot to remove some debug output.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16881 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-26 17:11:43 +00:00
Axel Dörfler
c14a34a65f * Improved kernel ELF loader (and made it more similar to the one from the boot
loader): it now supports holes between segments, and accepts any segment order.
* Renamed elf.c to elf.cpp and fixed warnings.
* Renamed elf_image_info::dynamic_ptr and eheader to dynamic_section and elf_header.
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16878 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-26 15:58:43 +00:00
Axel Dörfler
342c2a73ab Improved debug output.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16871 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-24 21:27:01 +00:00
Axel Dörfler
5ba2a3839d Improved the filter capabilities of the "ports", "port", "sems", and "areas" debugger commands.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16870 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-24 12:59:23 +00:00
Axel Dörfler
db823da57e * Even though our current heap is a temporary solution, the heap size depends
now on the amount of memory installed in the system. Ie. if you have only
  128 MB the kernel heap will be only half in size.
* Minor cleanup in vm_page.c, renamed some variables to match our style guide.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16838 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-19 15:02:21 +00:00
Axel Dörfler
5f0bf2a3e1 We now track how many pages are in a vm_cache. Therefore, the area_info.ram_size
now reflects the number of pages in the areas cache, instead of just the size of the
area.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16834 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-18 20:17:31 +00:00
Axel Dörfler
66b7a0f477 Renamed the _kern_init_heap_address_range() syscall to _kern_reserve_heap_address_range()
and made it more powerful.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16825 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-18 12:52:01 +00:00
Axel Dörfler
c864c43bab Fixed warning I just introduced.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16793 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-14 20:29:50 +00:00
Axel Dörfler
baf7b0adf0 Broke the build once more: didn't remember that gettimeofday() was built
for the kernel as well, and thus we need to export _kern_get_timezone(),
too.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16792 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-14 20:22:50 +00:00