Commit Graph

986 Commits

Author SHA1 Message Date
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
3f86eca54a Removed glibc's dprintf() from libroot.so. It clashes with the dprintf()
defined by the UserlandFS server and is of no real use anyway.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20457 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-03-28 22:15:11 +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
Oliver Tappe
07628e25b1 * changed to use TARGET_CC instead of host as.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20229 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-25 15:47:10 +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
Ingo Weinhold
8d96648eab Fixed build.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20134 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-15 18:59:45 +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
Ingo Weinhold
2cddddacba Made _gHaikuRevision static and renamed it to sHaikuRevision.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20093 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-07 13:01:28 +00:00
Ingo Weinhold
a4e0c1d43d * We do now have a special "_haiku_revision" section in our libroot,
containing the Haiku SVN revision number which is used by uname(). The
  value is 0 when built, but updated by the build system before copying
  libroot to the image (new rule CopySetHaikuRevision).
* For AboutHaiku we no longer write the SVN revision number into a
  resource. Instead we use the uname() info.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20082 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-06 16:51:29 +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
Jérôme Duval
bf63295e0b reverted changes from revision 7340, it seems to not be useful anymore.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20063 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-04 11:48:08 +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
Ingo Weinhold
550f2171c1 Mostly aesthetical changes. "jam pxehaiku" worked here before and still
does. Marcus, what problem did you encounter?

The BuildPXEstage1 actions use "as" ATM, which is not correct, since it
should actually use the target platform assembler (i.e.
cross-compilation won't work). It should be replaced by $(TARGET_CC),
but that results in the following errors, when compiling with gcc 2.95.3:

/home/bonefish/develop/haiku/haiku/src/system/boot/platform/pxe_ia32/pxe_stage1.S:
Assembler messages:
/home/bonefish/develop/haiku/haiku/src/system/boot/platform/pxe_ia32/pxe_stage1.S:39:
Error: missing ')'
/home/bonefish/develop/haiku/haiku/src/system/boot/platform/pxe_ia32/pxe_stage1.S:96:
Error: `0x6(%edx)' is not a valid 16 bit base/index expression
/home/bonefish/develop/haiku/haiku/src/system/boot/platform/pxe_ia32/pxe_stage1.S:102:
Error: `0xa(%edx)' is not a valid 16 bit base/index expression
/home/bonefish/develop/haiku/haiku/src/system/boot/platform/pxe_ia32/pxe_stage1.S:127:
Error: `2(%edx)' is not a valid 16 bit base/index expression
/home/bonefish/develop/haiku/haiku/src/system/boot/platform/pxe_ia32/pxe_stage1.S:128:
Error: `0(%edx)' is not a valid 16 bit base/index expression
/home/bonefish/develop/haiku/haiku/src/system/boot/platform/pxe_ia32/pxe_stage1.S:147:
Error: `16(%ebx)' is not a valid 16 bit base/index expression
/home/bonefish/develop/haiku/haiku/src/system/boot/platform/pxe_ia32/pxe_stage1.S:149:
Error: `20(%ebx)' is not a valid 16 bit base/index expression
/home/bonefish/develop/haiku/haiku/src/system/boot/platform/pxe_ia32/pxe_stage1.S:173:
Error: `2(%edx)' is not a valid 16 bit base/index expression
/home/bonefish/develop/haiku/haiku/src/system/boot/platform/pxe_ia32/pxe_stage1.S:174:
Error: `0(%edx)' is not a valid 16 bit base/index expression
/home/bonefish/develop/haiku/haiku/src/system/boot/platform/pxe_ia32/pxe_stage1.S:298:
Error: `(%esi)' is not a valid 16 bit base/index expression
/home/bonefish/develop/haiku/haiku/src/system/boot/platform/pxe_ia32/pxe_stage1.S:299:
Error: `(%edi)' is not a valid 16 bit base/index expression
/home/bonefish/develop/haiku/haiku/src/system/boot/platform/pxe_ia32/pxe_stage1.S:306:
Error: `(%esi)' is not a valid 16 bit base/index expression
/home/bonefish/develop/haiku/haiku/src/system/boot/platform/pxe_ia32/pxe_stage1.S:307:
Error: `(%edi)' is not a valid 16 bit base/index expression


For the gcc 4 configuration all but the first errors disappear. It looks
like these are bugs in older assembler version. Any reasonable
work-around?



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20043 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-02 09:42:22 +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
Philippe Houdoin
7029621374 Added forgotten space between kernel build date and time.
Also prepare uname to return the build SVN revision number,
which will work only if I could figure out how to define it from Jamfile.
Or, better, in build/jam/BuildSetup. 


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20023 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-30 22:30:01 +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
923ce6f922 * waitpid() now only clobbers _status in case it succeeded.
* improved comments and TODOs.
* added note about unimplemented WUNTRACED, and WCONTINUED options


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20011 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-29 15:45:34 +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
1beeb96080 setpgrp() returns a pid_t, not an int.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20008 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-29 13:31:24 +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
f0a5326923 * Made all exported safe against NULL pointers, this fixes bug #485.
* Slightly improved error codes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19941 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-24 14:32:05 +00:00
Axel Dörfler
a9d09fc255 Added _kstatfs_() for binary compatibility with some BeOS apps (most notably, SoftwareValet).
We might want to remove it again once we have a replacement for it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19929 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-23 21:01:18 +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
Jérôme Duval
5efe9479fe ACPI boot menu item is for bios_ia32
added a kernel settings option to disable ACPI



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19791 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-13 19:55:14 +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