Commit Graph

4839 Commits

Author SHA1 Message Date
Fredrik Holmqvist
87dfde44f7 Stop using glibc's asm strlen and use our own.
Mostly done because olta want less dependency on glibc.
It should also make porting a tiny bit simpler.

Testresults, mean values on Haiku from libMicro:
 * with glibc: strlen_10: 0.03859S, strlen_1k: 1.67075S.
 * with strlen.cpp: strlen_10: 0.03854S, strlen_1k: 1.66938S.

So at least on my machine it's possible to beat glibc ;)
2011-12-29 17:41:03 +01:00
Fredrik Holmqvist
55cf69968f Rename strlen.c strnlen.c to strlen.cpp strnlen.cpp.
No changes in the files themselves in this commit.
2011-12-29 15:43:23 +01:00
Oliver Tappe
f4995c1381 Improve timezone names returned by POSIX functions.
* Use TimeZone::SHORT specifier instead of SHORT_COMMONLY_USED, since
  the former yields more appropriate (textual) values. Strangely enough,
  it used to be the other way around, which is why we didn't used SHORT
  in the past.
2011-12-27 14:14:55 +01:00
Fredrik Holmqvist
7928259c69 Style fixes. No functional changes.
* Parameter renamed from s to string.
 * HasZeroByte renamed to LACKS_ZERO_BYTE and the check is inverted.
 * Removed space between cast and variable.
2011-12-26 18:24:22 +01:00
Fredrik Holmqvist
11048d3619 Reworked strlen and strnlen to follow style guide.
Fix problems pointed out by Marcus.
2011-12-25 17:00:31 +01:00
Fredrik Holmqvist
753a02c156 Reworked strlen and strnlen to look at four bytes at the time. From what I understand this should be safe.
Based on info from bit twiddling hacks: http://graphics.stanford.edu/~seander/bithacks.html
2011-12-24 22:27:44 +01:00
Oliver Tappe
2ba22cc36a Fix crash of AboutSystem on gcc4.
* Glibc declares and uses its own version of mbstate_t, which is
  incompatibly with our own. Mix our own fields into glibc's
  mbstate_t, such that the two structs are compatible.
2011-12-19 18:49:16 +01:00
Oliver Tappe
ec99f3b2a6 Adjust mbstate_t to embed the state of the ICU converter.
* make room in mbstate_t for containing an ICU-converter's state
  (well, in fact the whole converter object)
* adjust libroot's locale add-on to clone converters into a given
  mbstate_t directly
* adjust ICUThreadLocalStorageValue to contain the converter pointer
  instead of a converter-ID (if the converter is related to an
  mbstate_t, it points into the mbstate_t).
* adjust users of converters to directly use converter pointers
  instead of ICUConverterRef
* drop now unused ICUConverterManager and ICUConverterRef
* update gcc4 optional package

This brings our multibyte implementation into a fully working state,
both non-ascii and non-8-bit characters can now be handled normally
in the Terminal, i.e. this finally fixes #6276.

N.B.: Since the size of mbstate_t has changed, everything (including
the compiler!) needs to be rebuilt.
2011-12-15 13:18:11 +01:00
John Scipione
0e35d5d2e5 Change instances of wether in comments to whether. No functional change intended. 2011-12-12 14:41:49 -05:00
Oliver Tappe
5de93d5b1f Adjust libroot to invoke internal (__...) mbs-functions. 2011-12-12 17:27:44 +01:00
Oliver Tappe
8703b5fdf5 Fix gcc4-build and handling of src-pointer upon error.
* the reference to MB_CUR_MAX requires stdlib.h
* if an conversion error occurs, the returned src pointer must point to
  the character that triggered the error
2011-12-12 17:27:44 +01:00
Oliver Tappe
70dda8d85a Fix POSIX-specific mbsrtowcs() and wcsrtombs().
* src was sometimes accessed incorrectly (needs double dereference)
* the source pointers may only be adjusted in case there is the
  destination pointer is not NULL
2011-12-12 17:27:43 +01:00
Oliver Tappe
0ad71bca30 Simplify wcrtomb() wrapper.
* since the backend now supports it, we can safely pass NULL as s
  to the backend
2011-12-12 17:27:43 +01:00
Oliver Tappe
47e0423a09 Drop public symbols for mbsnrtowcs() and wcsnrtombs().
We only implement POSIX_VERSION 199009, so these needn't be exported.
2011-12-12 17:27:43 +01:00
Oliver Tappe
0cf89c88d3 Activate our own wcs*tombs()-functions.
* add our own version of these functions to the build
* drop the glibc implementations of those functions
2011-12-12 17:27:42 +01:00
Oliver Tappe
995d6d827f Implement our own version of wcsrtombs().
* add WcharStringToMultibyte() to libroot's locale backend
* implement wcstombs(), wcsrtombs() and wcsnrtombs() on top of that
  new backend function
2011-12-12 17:27:42 +01:00
Oliver Tappe
b8b6531011 Add implementation for mbstowcs().
* implement mbstowcs() on top of mbsrtowcs()
* drop glibc's version of mbstowcs()
2011-12-12 17:27:42 +01:00
Oliver Tappe
73186b2fcd Add implementation of mbsrtowcs() to our locale backend.
* add MultibyteStringToWchar() to ICU locale backend
* implement mbsrtowcs() and mbsnrtowcs() on top of 
  MultibyteStringToWchar()
* drop respective glibc files
2011-12-12 17:27:41 +01:00
Oliver Tappe
d0e7bc307c Reset ICU-converter in case of error. 2011-12-12 17:27:41 +01:00
Oliver Tappe
cf13327bef Whitespace cleanup. 2011-12-12 17:27:40 +01:00
Michael Lotz
6ef7d359c7 ASSERT() that there really aren't any wired pages. 2011-12-11 17:08:10 +01:00
Michael Lotz
af09f123d3 Create the right cache type ([non-]swappable) on copy on write.
When forking a team, copy on write areas (and therefore caches) are
created for all the areas in the parent team, but they were always
created as swappable. If the parent team had some B_FULL_LOCK areas,
which aren't swappable, the wrong type of cache would be created which
lead to them not being mergeable later on (causing a panic).

Comments about a possibly cleaner way to figure out the cache type
would be welcome.
2011-12-11 17:08:10 +01:00
Jérôme Duval
86216323af Fixed math.h part of #2696
* added lgammal_r wrapper
* removed gamma_r and gammaf_r functions from math.h
2011-12-11 12:28:53 +01:00
Jérôme Duval
04fccd250f added hcreate, hdestroy, hsearch from glibc 2011-12-11 10:49:18 +01:00
Michael Lotz
44c3f5c188 Clean up the mess added in hrev43461 and solve it differently.
* Define a MEMALIGN macro that is either just defined to malloc() or
  to the actual memalign() depending on where KMessage is used. We only
  use memalign() inside the kernel and libroot.
* Add a comment to the macro explaining that this allows the use of
  special heap implementations that might return unaligned buffers for
  debugging purposes.
2011-12-10 23:20:18 +01:00
Michael Lotz
e339322a88 Fix hrev43405 by moving the reference above the autolocker.
The change in hrev43405 wasn't correct, as it put the reference
object definition after the one of the corresponding locker, causing
the reference to be released before the unlock would happen.

Finally fixes #8187. Thanks Ingo for pointing that out.
2011-12-10 21:35:40 +01:00
Michael Lotz
5585262bb1 Revert hrev43455 and instead just align the size.
While this isn't really correct, it works for the use case it is
intended and doesn't open the can of worms we get when trying to do
memalign() across platforms (due to build tools use of KMessage).
2011-12-10 21:03:14 +01:00
Michael Lotz
33f0ed7a03 Revert hrev43457.
This reverts commit 82929f8a76.
2011-12-10 21:03:13 +01:00
Michael Lotz
8eff10a8bf Revert hrev43458.
This reverts commit 80e6a84bf0.
2011-12-10 21:03:13 +01:00
Michael Lotz
a173514ad1 Revert hrev43459.
This reverts commit c8a48d783c.
2011-12-10 21:03:12 +01:00
Michael Lotz
c8a48d783c Same as hrev43457 (- the error) but for the bootloader heap. 2011-12-10 19:15:10 +01:00
Michael Lotz
80e6a84bf0 Fix alignment mask, sorry for the noise. 2011-12-10 19:09:30 +01:00
Michael Lotz
82929f8a76 Add a simplistic memalign() to the runtime_loader heap.
As KMessage now makes use of memalign() the simple heap in the
runtime_loader needs to provide that as well. Fixes build.
2011-12-10 19:07:33 +01:00
Michael Lotz
9a87646122 Only free the old buffer if we owned it and set owning flag.
* If we cloned the buffer due to misalignment, only free the old buffer
  if we actually own it (i.e. if it was allocated by us).
* Set the KMESSAGE_OWNS_BUFFER flag after cloning the buffer. Previously
  the buffer was leaked in the clone case.
2011-12-10 18:46:29 +01:00
Michael Lotz
d0aa07489c Ensure proper alignment instead of just checking for it.
* If there is an alignment requirement then better use memalign() to
  make sure that it is met.
* Since the BMessageAdapter possibly sets a buffer directly, make a
  properly aligned copy of the buffer if it happens to be misaligned.
2011-12-10 17:55:47 +01:00
Michael Lotz
268ddbd76f Fix a few function signatures in the guarded heap.
* Not including malloc.h caused the memalign() signature to not be a C
  signature, therefore leading to linking errors. Fix the missing
  include and explicitly add extern "C" as well.
* Some remaining asterisk style cleanup.
2011-12-10 17:24:10 +01:00
Michael Lotz
3de380692a Update the guarded heap areas after fork.
We don't actually use them for anything yet though.
2011-12-10 17:24:09 +01:00
Michael Lotz
97680106f0 Add a userland version of the guarded heap to libroot_debug.
The guarded heap uses mprotect() to protect freed/unallocated pages so
that any access to such a page results in a segfault. It also installs
a segfault handler that in such an event prints some info about the
accessed page and then calls the debugger with a meaningful message.

It implements the same interface as the debug heap so it can simply be
swapped out by changing the Jamfile. As it doesn't support most of the
extra debug features (wall checking is obviously superfluous, but it
also doesn't help in leak checking) and as it is hugely space
inefficient I left it disabled for now.
2011-12-07 00:40:47 +01:00
Michael Lotz
5e5eef0b5b Fix the page need calculation, it was possibly off by one. 2011-12-07 00:09:31 +01:00
Michael Lotz
da3ce43440 Erase the entry only after its last use. CID 11042. 2011-12-06 20:00:48 +01:00
Michael Lotz
ded69b4c3a Only the to be protected range needs to be non-wired.
When setting memory protection, only ensure/wait for the range that
needs to be protected to not be wired instead of requiering the whole
area to be non-wired. The memory protection is done page wise and
having some parts of the area wired shouldn't preclude other parts to
be protected.
2011-12-06 15:39:56 +01:00
Michael Lotz
62bb375688 Restructure wait_for_thread_etc() to make it easier to follow.
* Avoid needless adding of the death entry if the sem is gone already.
* Delete objects as soon as they aren't needed anymore and return
  early where possible.
* Contain the thread == NULL case in its block and return from there as
  well instead of non-obviously figuring out what happened later.
* Pull out the return code asignment.
* Minor cleanup.
2011-12-06 02:30:17 +01:00
Michael Lotz
da329fc012 Add missing asignment of return code in wait_for_thread_etc().
While it was detected that the thread is in the destruction phase
and that it was necessary to wait and then have a valid status code
in the death entry, that status code wasn't actually returned. This
lead to uninitialized values for the return code even though
wait_for_thread[_etc]() would return B_OK.
2011-12-06 01:53:27 +01:00
Michael Lotz
2872aba0a7 Fix missing reference to the old group with lock still held.
Removing the team from the group may have released the last reference
to the group and freed it. Since we still have a locker on that group
it would later crash on unlock, therefore we need a reference to the
old group before removing the team from it.
2011-12-04 20:14:24 +01:00
Michael Lotz
336967aafd Add more debugger commands to closer inspect the guarded heap. 2011-12-04 18:47:55 +01:00
Michael Lotz
4a7b48203e Try smaller sizes if creating an area failed.
Depending on the use case the grow size may be too large to fit into
address space holes. Instead of failing try with smaller sizes until
it either worked or doesn't make sense anymore (< 1MB).
2011-12-04 18:43:20 +01:00
Michael Lotz
01eb710a91 Use a free list to make the guarded heap perform less horribly.
Pages that are freed are added to the tail of the list while allocation
candidates are taken from the head. Therefore pages that have been free
the longest are preferred, making immediate re-use less likely.

Also avoid looking for pages if the free count already tells that the
allocation can't be fulfilled.
2011-12-04 18:40:11 +01:00
Michael Lotz
5cbe06f482 Allow replacing the object cache with the guarded heap.
This allows to use the debug features of the guarded heap also on
allocations made through the object cache API. This is obivously
horrible for performance and uses up huge amounts of memory, so the
initial and grow sizes are adjusted accordingly.

Note that this is a rather simple hack, using the object_cache pointer
to transport the allocation size. The alignment is neglected completely.
2011-12-04 13:52:06 +01:00
Michael Lotz
390a6e2e02 Add support for optional inline stack traces in guarded heap. 2011-12-04 12:56:59 +01:00
Michael Lotz
01762bd57f Fix possibly harmful use of stale pointer in edge case.
The call to _MakeSpace() may move the extent data from the indirect
array (kept in a heap allocation) to the direct one kept inside the
class. In that case the lastExtent pointer would become stale and
further use of it would've lead to suboptimal extents in the best case
to reading/writing at the wrong point in files and possibly corruption
of another allocation in the worst (both unlikely though).

To mitigate that we now re-initialize the pointer to the correct location
if we hit the cache limit.

Also made the use of the start variable more understandable. Instaed of
decrementing it (possibly wrapping) when an extent wasn't going to be
used and later adding the vector index again, just increment whenever
we actually move to the next extent.

For bad things to happen a few conditions needed to come together though:
1. There needed to be multiple vectors that could be combined with the
existing last extent.
2. There first needed to be more extents than the cache limit and that
number then had to decrease below the cache limit again.
3. The memory needed to stay intact after being freed up until after the
evaluation (or similar enough data had to be written to it).

At least the last one was guaranteed to not be true anymore since we
re-introduced overwritting freed memory with 0xdeadbeef in the slab,
therefore nastily hiding this. I'm not sure that the first condition is
ever met either (probably the vectors are combined beforehand so that
there never are multiple adjacent ones) at least for the normal use case
(the page writer writing back pages). I was at least unable to reproduce
an actual file corruption in my testing.

Just the out of bounds access to the stale pointer happened rather easily
though and is now at least fixed.
2011-12-03 23:30:16 +01:00
Michael Lotz
e62d9911ea Allocate as much as is later read, didn't do harm though.
Further in the process the flat argument size is rounded up, but the
actual allocation was done with the unaligned size causing an access
beyond the allocation when later copying the flat arguments. It didn't
do any actual harm as the block sizes of our allocator(s) use elements
that have at least such an alignment.
2011-12-03 23:13:52 +01:00
Michael Lotz
1fe24d0cd0 Add heap with guard pages to detect out of bound reads/writes.
This is a very simple heap implementation that allocates memory so that
the end of each allocation always coincides with a page end and is
followed by a guard page which is marked non-present. Out of bounds
access (both read and write) therefore cause a crash (unhandled page
fault).

Note that this allocator is neither speed nor space efficient, indeed it
wastes huge amounts of pages and address space so it is quite easy to
hit limits. It is intended as a pure debug feature.
2011-12-03 20:09:13 +01:00
Michael Lotz
7418dbd908 Introduce debug page wise kernel area protection functions.
This adds a pair of functions vm_prepare_kernel_area_debug_protection()
and vm_set_kernel_area_debug_protection() to set a kernel area up for
page wise protection and to actually protect individual pages
respectively.

It was already possible to read and write protect full areas via area
protection flags and not mapping any actual pages. For areas that
actually have mapped pages this doesn't work however as no fault, at
which the permissions could be checked, is generated on access.

These new functions use the debug helpers of the translation map to mark
individual pages as non-present without unmapping them. This allows them
to be "protected", i.e. causing a fault on read and write access. As they
aren't actually unmapped they can later be marked present again.

Note that these are debug helpers and have quite a few restrictions as
described in the comment above the function and is only useful for some
very specific and constrained use cases.
2011-12-03 19:49:18 +01:00
Michael Lotz
643cf35ee8 Add debug helper functions to mark pages present.
They can be used to mark pages as present/non-present without actually
unmapping them. Marking pages as non-present causes every access to
fault. We can use that for debugging as it allows us to "read protect"
individual kernel pages.
2011-12-03 19:45:31 +01:00
Michael Lotz
a139657921 Tracking info wasn't always retrieved with the cache locked.
Getting the object slab does a hash lookup which needs to be protected
by the cache lock. Otherwise the hash table may be resized or otherwise
modified while we do the lookup, leading to errors.
2011-11-29 00:15:34 +01:00
Philippe Saint-Pierre
d9a215b71f Comparison with an unsigned value (size_t) and < 0
CID 4190 and CID 4191
2011-11-27 00:21:41 -05:00
Philippe Saint-Pierre
552d99013a Replace usage of sprintf with snprintf
Fixing CID 10964
2011-11-26 20:17:46 -05:00
Michael Lotz
79f0056002 Fix virtual 8086 mode to properly account for TLS.
* The vm86 code or the code running in virtual 8086 mode may clobber the
  %fs register that we use for the CPU dependent thread local storage
  (TLS). Previously the vm86 code would simply restore %fs on exit, but
  this doesn't always work. If the thread got unscheduled while running
  in virtual 8086 mode and was then rescheduled on a different CPU, the
  vm86 exit code would restore the %fs register with the TLS value of
  the old CPU, causing anything using TLS in userland to crash later on.
  Instead we skip the %fs register restore on exit (as do the other
  interrupt return functions) and explicitly update the potentially
  clobbered %fs by calling x86_set_tls_context(). This will repopulate
  the %fs register with the TLS value for the right CPU. Fixes #8068.

* Made the static set_tls_context() into x86_set_tls_context() and made
  it available to others to faciliate the above.

* Sync the vm86 specific interrupt code with the changes from hrev23370,
  using the iframe pop macro to properly return. Previously what was
  pushed in int_bottom wasn't poped on return.

* Account for the time update macro resetting the in_kernel flag and
  reset it to 1, as we aren't actually returning to userland. This
  didn't cause any harm though as only the time tracking is using that
  flag so far.

* Some minor cleanup.
2011-11-25 16:10:19 +01:00
Ingo Weinhold
dbe2a683f0 find_directory(): Fix package links path 2011-11-25 06:19:48 +01:00
Ingo Weinhold
bde1972229 Move <directories.h> to headers/private/system 2011-11-25 06:19:32 +01:00
Ingo Weinhold
04999b6cf9 Completed vfs_bind_mount_directory() support
We don't need to explicitly track the covered/covering nodes per mount
after all. In fs_unmount() we iterate through all vnodes multiple times
anyway and can deal with the covers/covered_by vnodes there. Also, the
root vnode doesn't need to be handled specially anymore.
2011-11-25 06:17:49 +01:00
Ingo Weinhold
1b08a68a4f vfs_bind_mount_directory(): Fail if unmounting 2011-11-25 06:17:48 +01:00
Ingo Weinhold
8855625e9e fix_dirent(): Fix ref count leaks
* Only get an additional parent reference, when going to call
  vnode_path_to_vnode().
* Put the reference of the vnode vnode_path_to_vnode() returns.
2011-11-25 06:17:47 +01:00
Ingo Weinhold
e4320fd78c remove_vnode(): Also consider covering vnode busy 2011-11-25 06:17:47 +01:00
Ingo Weinhold
54e721afeb Add support for bind-mounting directories
* Add support function vfs_get_mount_point(), so a file system can get
  its own mount point (i.e. the node it covers). Re-added
  fs_mount::covers_vnode for that purpose -- the root node isn't know to
  the VFS before the mount() hook returns.
* Add function vfs_bind_mount_directory() which bind-mounts a directory
  to another. The Vnode::covers/covered_by mechanism is used, so this
  isn't true bind-mounting, but sufficient for what we need ATM and
  cheaper as well. The vnodes connected thus aren't tracked yet, which
  is needed for undoing the connection when unmounting.
* get_vnode_name(): Don't use dir_read() to read the directory. Since we
  have already resolved vnode to the covered vnode, we don't want the
  dirents to be "fixed" to refer to the covering nodes. Such a vnode
  simply wouldn't be found.
2011-11-25 06:17:44 +01:00
Ingo Weinhold
f4a1387cea Add vfs_ prefix to resolve_vnode_to_covering_vnode() 2011-11-25 06:17:44 +01:00
Ingo Weinhold
47ea54c55b Generalize use of Vnode::covered_by/covers
* Introduce Vnode flags for covered and covering. Can be used as a quick
  check when one doesn't already hold sVnodeLock.
* Rename resolve_mount_point_to_volume_root() to
  resolve_vnode_to_covering_vnode().
* Adjust all code that deals with transitions between mount points and
  volume root vnodes to generally support covered/covering vnodes.
2011-11-25 06:17:43 +01:00
Ingo Weinhold
02be66ca10 Replaced fs_mount::covers_vnode by Vnode::covers
Introduce a Vnode::covers field. It is currently only used for the root
node of an fs_mount, replacing fs_mount::covers_vnode.
2011-11-25 06:17:42 +01:00
Ingo Weinhold
7bb72b8daf Comment typo fixes 2011-11-25 06:17:41 +01:00
Ingo Weinhold
37c83f4e8f Made the check for B_BUFFER_OVERFLOW more flexible. 2011-11-25 06:17:30 +01:00
Oliver Tappe
323b65468e Filtered flat import of Oliver's svn package management branch
Bring the changes that aren't package management related and the ones
that are but don't take effect as long as they are ignored by the build
system into the master.

Summary of changes:
* Introduce private header <directories.h> with constants for a good
  deal of paths that should usually be retrieved via find_directory().
* Replace hard-coded paths by using find_directory() or the
  <directories.h> constants (e.g. in drivers and the kernel).
* Add find_directory() constants needed for package management.
* Add __HAIKU_ABI_NAME and B_HAIKU_ABI_NAME macros.
* src/apps/deskbar: BeMenu.* -> DeskbarMenu.*,
  DeskBarUtils.* -> DeskbarUtils.*
* Change deskbar menu settings directory from ~/config/be to
  ~/config/settings/deskbar.
* Other smaller cleanups, changes, and fixes.
2011-11-25 06:17:07 +01:00
Oliver Tappe
8fd51c0819 Use ErrnoMaintainer in setlocale() to protect errno.
* this avoids spurious errno changes leaking into application code,
  which could become confused - i.e. 'rm' on a gcc4 build would always
  prompt for confirmation

I spend a couple of hours hunting down the behavioural difference
between gcc2- and gcc4-builds and it turns out that the reason for that
is that gcc4's libstdc++-code initializes its own locale data via the
POSIX calls, which trigger (correct) errno value changes, which were the
ones leaking into application code.
2011-11-24 23:48:19 +01:00
Oliver Tappe
59e43b2ac9 Add tracing to some locale backend functions. 2011-11-24 23:48:18 +01:00
Oliver Tappe
ae90193596 Introduce __set_errno() throughout libroot.
* add errno_private.h, which defines the __set_errno() macro with
  and without tracing
* instead of setting errno manually, all libroot's code now invokes
  __set_errno(), which makes it much easier to trace changes to errno
* redirect glibc's use of __set_errno() to our own version
2011-11-24 23:48:18 +01:00
Oliver Tappe
c894d1868e Bring rewritten multibyte-support into repository.
* update copyrights of locale backend files

Multibyte-support has been rewritten to use ICU as backend.
While this does not necessarily work properly in every aspect
(e.g. the shell still has [different] problems with multibyte-
characters now), it does fix #6263 and #7700.
2011-11-23 19:55:34 +01:00
Oliver Tappe
53c09cffcb Actually store & use our assigned TLS-key (OOPS!) 2011-11-23 19:32:17 +01:00
Oliver Tappe
5c112a16ff Reset mbstate to initial in wcrtomb() with 0 wchar. 2011-11-23 19:31:13 +01:00
Oliver Tappe
9161a59746 Fix build of libroot-addon-icu with gcc4. 2011-11-22 23:27:17 +01:00
Oliver Tappe
bb79d18614 Drop no longer needed multibyte stuff from glibc. 2011-11-22 18:56:41 +01:00
Oliver Tappe
b4435552a7 Drop our old, limited multibyte implementation. 2011-11-22 18:38:43 +01:00
Oliver Tappe
cc5eca7554 Activate our new multibyte implementation.
* add implementations for the following multibyte-related
  functions:
    btwoc()
    mblen()
    mbrlen()
    mbrtowc()
    mbsinit()
    mbtowc()
    wcrtomb()
    wcswidth()
    wctob()
    wctomb()
* the implementation of the above function live in a symbol
  named __<name>, the above symbol names are defined as a weak
  alias to the internal ones - TODO: we need to make sure to
  only invoked the internal functions (i.e. prepended with __)
  in order to avoid problems with symbol preemption.
* deactivate the limited mb implementation we provided before,
  as well as respective stuff from glibc
2011-11-22 18:31:27 +01:00
Oliver Tappe
28ae43d033 Add multibyte-support to ctype-locale backend.
* add actual converter methods MultibyteToWchar() and WcharToMultibyte()
  to locale backend and implement them in the ctype subpart
* add management code for maintaining converters referenced by mbstate_t
2011-11-22 18:17:58 +01:00
Oliver Tappe
e0eb1d38c4 Let MB_CUR_LEN lookup the actual value.
* instead of yielding 1, MB_CUR_LEN now looks up the correct
  value in the ctype data provided by the locale backend
2011-11-22 17:32:39 +01:00
Oliver Tappe
bf5ff48092 Use TLS and converter manager in locale backend. 2011-11-22 17:17:18 +01:00
Oliver Tappe
bcadc4ca66 Start work on multibyte-support in locale backend.
* add ICUThreadLocaleStorageValue, which will be used to maintain
  per-thread ICU converters
* add ICUConverterManager
2011-11-22 16:55:39 +01:00
Oliver Tappe
3a57f54e4d Glibc-features: protect against existing __STDC_ISO_10646__.
* we define it in our compilers now, but glibc expects to define
  this itself - we let our own version overrule
2011-11-22 16:34:18 +01:00
François Revol
a8eaac6934 U-Boot: board-specific setup is already in build/jam/board/ 2011-11-22 02:27:11 +01:00
François Revol
75e4ff02d0 Style cleanup 2011-11-21 03:19:31 +01:00
François Revol
1cdb5905fc U-Boot: Print the panic message also to the serial port
It seems puts() currently hangs when used in panic(), will need some more work.
2011-11-21 03:00:07 +01:00
François Revol
70ac17baab U-Boot: Cleanup; s/arm/$(TARGET_ARCH)/g
U-Boot is not only about arm...
2011-11-21 01:36:43 +01:00
François Revol
d1460ff57b ARM: Rename flash and mmc base generic targets
They are not so much arm-specific, really.
We now have haiku-flash-*image variations,
and haiku-mmc-image.
2011-11-21 01:30:02 +01:00
François Revol
1d6f7e86ee ARM: Use proper Jamfiles for u-boot/arch/ subdirs 2011-11-21 01:22:32 +01:00
François Revol
e3591817b3 ARM: move kernel calling code to arch specific file
* needs some more cleanup.
* had to change gUBootOS to 32bit to avoid a linker bug.
2011-11-21 01:22:32 +01:00
Michael Lotz
8a5fb91c07 Stricter tests for PCI bridges at interrupt routing.
Validate the candidate child device a bit more by checking the device ID
and the base and subclass of the device. We don't even know if the child
is still on the PCI bus and some firmware may mark disabled devices by
simply invalidating one of these values. Possibly fixes #8111.

Added TODO concerning that we might not want to fail at all since we
ensure that we matched all devices after routing preparation at which
state we would notice any missing child devices anyway.
2011-11-18 13:03:46 +01:00
Michael Lotz
35632c56af Fix harmless oversight marking pages with the wrong state.
While the log of hrev35726 says that unusable page ranges are supposed
to be marked with PAGE_STATE_UNUSED and allocated ones with
PAGE_STATE_WIRED, both actually marked with PAGE_STATE_UNUSED.
2011-11-16 11:06:46 +01:00
Michael Lotz
4200073542 Tiny optimization by skipping a no-op iteration.
We initialize the physicalPagesEnd from physical_memory_range[0] so
re-evaluating that range is a no-op.
2011-11-16 10:56:16 +01:00
Michael Lotz
3dbd9c1148 Fix the LIMIT_AVAILABLE_MEMORY debug option.
When limiting the available memory by reducing the page count it may not
be enough to just limit sNumPages. Depending on the physical memory map
non existing pages between ranges (sNonExistingPages) would still be
added up and later subtracted from the sNumPages, resulting in a wrong
max page count. Also due to the fixed removal of non existing page
ranges the actually available memory would usually not be the amount
set via LIMIT_AVAILABLE_MEMORY.

Instead we now calculate the available memory when going through the
physical memory ranges and limit/exit as soon as we've reached the
desired amount of available memory (also ignoring further non-existing
pages).
2011-11-16 10:40:56 +01:00
Michael Lotz
c12f51264b Ensure the sanity of the stats returned, make the TODO a Note.
* Ensure that we don't underflow the used_pages count and that used
  + cached pages don't overflow max_pages. As there is no locking the
  values may change while we read them so that such situations could
  arise.
* Make the TODO about the missing locking into a Note explaining the
  above, as it is not really worth adding locking here. The stats are
  only informational.
2011-11-14 19:07:37 +01:00
François Revol
478dc9887e PPC: Preliminary untested boot support for Common Firmware Environment
CFE is used in the upcoming Amiga X-1000 dualcore PPC board.
* Largely inspired by the OF and U-Boot code.
* Still largely stubbed out.
* The loader builds but I don't have a machine to test it. Anyone interested?
2011-11-14 01:31:50 +01:00
Michael Lotz
5247333d36 Don't do the heap size calculation when using the slab as heap.
The initial heap size calculation only applies to the legacy/debug
heap, so it isn't needed when using the slab as kernel heap.
2011-11-13 22:20:24 +01:00
Michael Lotz
a28bab4790 Add the object pointers to the panic messages. 2011-11-13 22:18:29 +01:00
Michael Lotz
3733c51d38 Fix the computation of used memory and add a TODO.
* The altered used pages calculation of hrev43168 wasn't correct, as
  the inactive page queue may (validly) contain mapped pages as well.
  Those would then get counted twice (as they are included in
  gMappedPagesCount already).
  Instead we calculate the used pages from the total page count, minus
  everything we account for otherwise. Doing it this way is possible
  without introducing any additional counters, as all the counts to
  subtract are already present (as opposed to some of the ones that
  would be needed for adding the counts up). Fixes #8109.
* Added TODO regarding the problem of not locking any of the counters
  which runs the risk of them getting modified while we haven't yet read
  all of them.
2011-11-13 22:02:36 +01:00
François Revol
9638d7f4aa ARM: Use the serial port as console for now, as VT100.
* Subclass ConsoleNode as VTConsole
* use it to implement SerialConsole
* Use it as the default console for now to simplify debugging.
VTConsole could probably be factored out into boot/platform/generic/ someday.
2011-11-12 23:58:56 +01:00
François Revol
9e5b2c347a Fix typo. 2011-11-12 17:35:02 +01:00
Ingo Weinhold
ee87d51d97 Build fix
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43218 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-07 20:03:57 +00:00
Michael Lotz
a5c94bedb6 * Verify the MP config table signature and add some more sanity checks.
* Also reset the local and IO APIC base physical addresses when configuration
  failed.

Should fix #8102, but is otherwise untested for lack of old enough hardware.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43217 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-07 19:23:33 +00:00
Ingo Weinhold
fae2ce1945 Enlarge threads and ports KMessage notification stack buffers
They were too small for all the fields added. This is why the system
profiler skipped "thread added" notifications.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43216 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-07 19:22:02 +00:00
Ingo Weinhold
40287cba78 Add opt-in panic for KMessage buffer overflow
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43215 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-07 19:19:34 +00:00
Ingo Weinhold
65d7b9312b x86: Also set iframe::orig_{eax,edx} in TRAP_ERRC(). This makes
get_iframe_registers() in arch_user_debugger.cpp return the correct
eax/edx values also when the kernel was entered via an exception that
doesn't push an error code (e.g. page fault).
Fixes incorrect eax and edx values shown in Debugger and variable values
based on them.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43201 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-06 12:53:20 +00:00
Michael Lotz
90c6930ebb Add VM page allocation tracking similar to what happens in the slab already.
Introduces "page_allocation_infos" and "page_allocations_per_caller" KDL
commands.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43190 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-04 18:07:07 +00:00
Michael Lotz
905c75a595 Tiny pointer style cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43189 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-04 18:04:22 +00:00
Michael Lotz
75088a863b Move AllocationTrackingInfo into a header. This way it can be re-used outside
of the slab code. It is generic as it only contains the link to a tracing entry
and not any application specific info.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43188 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-04 18:03:34 +00:00
Michael Lotz
6d41dfd95c Move some of the trace entries around so that we know the page(s) they concern
and add that info to the trace entries.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43187 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-04 18:01:15 +00:00
Michael Lotz
865a0be1c0 Add optional stack traces to {Allocate|Free}Page[Run] tracing.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43185 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-04 17:58:50 +00:00
Michael Lotz
448d8d6fcb Indent cleanup only, no functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43184 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-04 17:57:42 +00:00
François Revol
9b74cc6637 Further reduced the region allocated for the uncompressed data to 8 MB.
Wastes a bit less time allocating pages for nothing, and makes debugging
mmu support less verbose as well.
The (gunzipped) tar file is still less than 4MB and will never be 8MB
realistically anyway.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43183 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-04 17:54:31 +00:00
François Revol
e5081da48c Large cleanup of the bootloader shell code. Replaced the x86 comment.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43182 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-04 17:22:01 +00:00
Rene Gollent
58ce0a2c12 When calculating the number of used pages for a get_system_info() request,
also include inactive pages. Fixes #7714.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43168 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-03 20:51:17 +00:00
François Revol
a4b79a647b Allow up to 2MB for the kernel, since it's already over 1MB.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43150 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-03 02:48:33 +00:00
François Revol
983b0dfa95 Fix building libroot on m68k.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43148 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-03 02:41:14 +00:00
François Revol
b29bbc9a80 Fix the bootloader build for m68k.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43146 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-03 01:09:49 +00:00
Ingo Weinhold
951c43ff21 Allocate VMKernelAddressRange and VMKernelArea in their own object
caches to reduce slab area fragmentation.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43136 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-02 22:04:37 +00:00
Ingo Weinhold
f8154d172d mmlr (distracted) + bonefish:
* Turn VMCache::consumers C list into a DoublyLinkedList.
* Use object caches for the different VMCache types and the VMCacheRefs.
  The purpose is to reduce slab area fragmentation.
* Requires the introduction of a pure virtual VMCache::DeleteObject()
  method, implemented in the derived classes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43133 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-02 21:14:11 +00:00
Ingo Weinhold
b0ee1941f3 Revert change that did accidentally sneak into the style cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43124 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-02 19:12:46 +00:00
Ingo Weinhold
ab3d6a3eaf Style cleanup. No functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43122 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-02 19:09:48 +00:00
Michael Lotz
3d1f420b23 bonefish+mmlr:
* Add "allocation_infos" KDL command. Can be used to print the allocation info,
  including the stack trace, given an object cache, slab, allocation within a
  slab or allocation address. It can also optionally be filtered by team/thread.
* Fix the AllocationDetailPrinterCallback to not access a possibly invalid
  trace entry for printing a stack trace.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43118 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-02 16:12:48 +00:00
Michael Lotz
81fea74394 bonefish+mmlr:
Add MemoryManager::DebugObjectCacheForAddress() to retrieve the ObjectCache for
a certain address from KDL.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43117 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-02 16:09:49 +00:00
Michael Lotz
9a79e531ef bonefish+mmlr:
* Introduce TracingMetaData::IsInBuffer() to validate that a certain memory
  range is within the valid tracing buffer limits.
* Use that when validating in tracing_is_entry_valid() before trying to access
  the entry, resolving a TODO.
* Validate the candidate time against the handed in time (if specified) as an
  additional check.
* Tiny unrelated text cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43116 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-02 16:02:07 +00:00
Michael Lotz
45cbd81436 Fix build with tracing disabled. Since capture_tracing_stack_trace() doesn't
return a stack trace when tracing is disabled we don't really need to be able
to print one either.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43088 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-01 22:49:32 +00:00
Ingo Weinhold
f606e8fd79 mmlr + bonefish:
* AllocationTrackingCallback::ProcessTrackingInfo(): Also pass the
  allocation pointer.
* "allocations_per_caller" KDL command: Add option "-d". When given,
  each allocation for the specified caller is printed, including the
  respective stack trace.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43087 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-01 22:26:23 +00:00
Ingo Weinhold
e32699b404 mmlr + bonefish:
Add ObjectCache::ObjectAtIndex().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43086 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-01 22:23:37 +00:00
Ingo Weinhold
328df922e6 mmlr + bonefish:
* Add TraceOutput::PrintArgs(), a va_list version of Print().
* Move code of TraceOutput::Print() to new private template function
  print_stack_trace().
* Add public tracing_print_stack_trace().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43085 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-01 22:22:14 +00:00
Michael Lotz
a5e2a43050 Fix the build with memory manager tracing disabled. The guard was missing
in the header.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43084 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-01 21:40:40 +00:00
François Revol
7014f7f3e4 Fix method name in trace.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43083 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-01 21:29:19 +00:00
Ingo Weinhold
50175c99c4 mmlr + bonefish:
Refactor the "allocations_per_caller" KDL command related functions.
They expect an instance of a class implementing the new
AllocationTrackingCallback interface, now. The only implementation ATM
is AllocationCollectorCallback, which does the work the now removed
slab_debug_add_allocation_for_caller() did before.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43082 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-01 21:16:14 +00:00
Ingo Weinhold
f908ff9bb6 mmlr + bonefish:
* Fix build broken in r43078. The slab_debug_add_allocation_for_caller()
  wasn't guarded correctly.
* slab_debug_add_allocation_for_caller(): Add bool resetAllocationInfos
  parameter, which makes the function clear the allocation tracking
  infos after processing the data.
* "allocations_per_caller" KDL command: Add option "-r" to reset the
  allocation tracking infos. The next invocation of the command will
  only show the allocations made after the reset.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43079 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-01 20:35:49 +00:00
Ingo Weinhold
0422a0f3ae mmlr + bonefish:
* dump_allocations_per_caller(): Compute the total allocation count and
  size from the caller infos instead of using return arguments in the
  helper functions called.
* Move caller info update code from analyze_allocation_callers() to new
  function slab_debug_add_allocation_for_caller(), so it can be reused.
* Add MemoryManager::AnalyzeAllocationCallers() to collect the
  allocation information for the memory manager.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43078 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-01 19:40:27 +00:00
François Revol
8fe82997ba Some more tracing.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43074 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-01 18:59:47 +00:00
François Revol
f6fbf32a02 Dump the 68040 mmu registers before touching them.
Added a comment about the Milan clone which uses the mmu in the BIOS to emulate Atari hardware, and the Transparent Translation registers to map the PCI bus, which screws up with our current code.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43073 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-01 18:58:18 +00:00
Ingo Weinhold
e1c6140eaa mmlr + bonefish:
* Add optional stack trace capturing for slab memory manager tracing.
* Add allocation tracking for the slab allocator (enabled via
  SLAB_ALLOCATION_TRACKING). The allocation tracking requires tracing
  with stack traces to be enabled for object caches and/or the memory
  manager.
  - Add class AllocationTrackingInfo that associates an allocation with
    its respective tracing entry. The structure is added to the end of
    an allocation done by the memory manager. For the object caches
    there's a separate array for each slab.
  - Add code range markers to the slab code, so that the first caller
    into the slab code can be retrieved from the stack traces.
  - Add KDL command "allocations_per_caller" that lists all allocations
    summarized by caller.
* Move debug definitions from slab_private.h to slab_debug.h.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43072 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-01 18:34:21 +00:00
Ingo Weinhold
69d7ad7dc5 mmlr + bonefish:
* Move struct tracing_stack_trace to tracing.h header.
* Add tracing_find_caller_in_stack_trace(). Helper function to get the
  first return address of a stack trace that is not in one of the given
  address ranges.
* Add AbstractTracingEntryWithStackTrace::StackTrace() getter.
* Add tracing_is_entry_valid(). Checks, based on the additionally given
  time, whether a tracing entry is (probably) still in the tracing
  buffer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43070 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-01 17:16:29 +00:00
Michael Lotz
485bb14c36 Prefix the heap version of the "allocations" debugger command with "heap_".
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43068 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-01 16:29:28 +00:00
Michael Lotz
5fd0416842 Tiny cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43063 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-11-01 14:27:25 +00:00
Michael Lotz
ffb6929a3b bonefish+mmlr:
Move blocking the 0xcccccccc and 0xdeadbeef address ranges from heap to VM init
so that it also works when used in the slab allocator.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43047 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-10-31 22:00:16 +00:00
Michael Lotz
72156a402f bonefish+mmlr:
* Introduce "paranoid" malloc/free into the slab allocator (initializing
  allocated memory to 0xcc and setting freed memory to 0xdeadbeef).
* Allow for optional stack traces for slab object cache tracing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43046 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-10-31 21:58:00 +00:00
Michael Lotz
fe8f0f4601 bonefish+mmlr:
* Add an AbstractTraceEntryWithStackTrace that includes stack trace handling.
* Add a selector macro/template combo to conveniently select the right base
  class depending on whether stack traces are enabled or not.
* Minor style cleanups.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43045 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-10-31 21:37:39 +00:00
Michael Lotz
ebf63109bb Tiny style cleanup. No functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43044 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-10-31 21:31:58 +00:00
Michael Lotz
a735bdebb9 Align all filesystem relevant places to use B_UNSUPPORTED for unsupported
instead of a mix of B_NOT_SUPPORTED and B_UNSUPPORTED. This allows checking for
a specific error code. Probably one of those should be phased out...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43025 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-10-31 10:18:03 +00:00
Michael Lotz
d3fdd8b180 Remove superflous test done a few lines above already.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43014 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-10-30 20:37:15 +00:00
Axel Dörfler
d817520f98 * Removed some dead code by applying a patch by lucian from ticket #6275,
thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42970 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-10-29 17:09:12 +00:00
Adrien Destugues
a1f2a6b179 Add cfmakeraw. Like cf{get/set}{i/o}speed, it iisn't POSIx standard but is used
often enough and simple enough to write that we should allow it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42865 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-10-16 16:44:17 +00:00
Michael Lotz
20f094cc38 Fix and add copyright year spotted by Urias.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42833 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-10-12 21:06:21 +00:00
Michael Lotz
fc2d7cb04d * Introduce {reserve|allocate|free}_io_interrupt_vectors() that can generically
be used to mark certain io interrupt vectors as reserved and to allocate from
  the still free ones. It is a kernel private API for now though.
* Make the MSI code use that functionality instead of implementing its own which
  slims it down considerably and also removes quite a bit of hardcoded knowledge
  about the interrupt layout that didn't really belong there.
* Mark the various in-use interrupts as reserved from the components that
  actually know about them (PIC, IO-APIC, SMP, APIC timer and interrupt setup).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42832 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-10-12 20:55:28 +00:00
Michael Lotz
2a77028057 Relax ensure_all_functions_matched() to assume no interrupt use when a device
has no routing information but wasn't configured by the BIOS either. The
function will now only panic if a device that was previously configured would
not be so anymore after enabling the IO-APIC. Fixes #7971.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42795 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-10-02 21:25:15 +00:00
Rene Gollent
17f2def171 Only call UserDefinedTimersRemoved if there actually are any. Should fix #7998.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42776 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-09-28 13:06:48 +00:00
Philippe Houdoin
d230708bcf * Expand kernel_args addresses ranges size, 8 is somewhat too small, leading
to a panic at boot.
* Make the panic message more explicit when there is no more room left.

This should hopefully fix #7869.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42715 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-09-05 10:49:32 +00:00
Jérôme Duval
920e575c03 As suggested by Ingo, revert r42648 and apply patch from Alex Smith provided in #7872. Thanks!
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42650 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-08-20 20:09:32 +00:00
Jérôme Duval
d29d58edea Disable interrupts when updating real time clock. Fixes #7872. Seems to have been introduced in r42116.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42648 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-08-20 17:46:50 +00:00
François Revol
4b9d794063 Add a hack to detect the Milan which boots with a black&white mode, to make the menu and console readable.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42641 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-08-19 12:15:57 +00:00
François Revol
f62ad34221 Add support for enumerating video modes using the Milan API and the ST/TT XBIOS calls. Not really tested, ARAnyM doesn't emulate the Milan stuff, and the ST resolutions aren't exactly chunky anyway (will need patching the framebuffer kernel args to include the mode/4CC instead of just bit depth).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42640 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-08-19 12:12:22 +00:00
François Revol
e45efadaad Complete the SCREENINFO structure definition; expose a single version of the Setscreen() calls, since they are just the same with magic values and extra args anyway.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42639 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-08-19 12:08:57 +00:00
Oliver Tappe
45f2f22b52 * update (not-so-)optional package ICU to 4.8.1, which contains interesting stuff
for message formatting
* adjust LocaleKit to use namespace 'icu', as ICU has been configured to no longer
  use a version specific namespace
* adjust LocaleKit to general API changes in ICU 4.8
Note: all software using ICU (like WebPositive) needs to be rebuilt!
Note: the ICU package for PPC needs to be updated before it can be used!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42638 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-08-18 22:13:06 +00:00
Axel Dörfler
d5e36fb599 * Introduced new fs_lopen_attr_dir() function that opens the attribute
directory of a file without traversing leaf links (just like lstat()).
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42620 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-08-10 21:08:00 +00:00
Axel Dörfler
33272012fb * Fixed reversed handling of O_NOTRAVERSE in attr_open(), and attr_create().
* Added support for O_NOFOLLOW for those two as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42619 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-08-10 20:53:06 +00:00
Axel Dörfler
b6455c080b * Implemented dladdr() in the runtime loader. This is like a gazillion times
faster than before.
* This also solves a TODO in dladdr(), although I did not use
  get_library_symbol() as I didn't quite see how that could fit as the comment
  suggested; there is now a new function get_symbol_at_address() for this.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42598 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-08-07 21:01:23 +00:00
Alexander von Gluck IV
40a5a5a0ac * Rename of_region type template as per Axel
* Rename of_support.h/cpp back to support.cpp as per Axel


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42498 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-07-26 16:42:14 +00:00
Alexander von Gluck IV
bf0e980dc4 * Fix a few style issues as per Axel
* Rename a few variables to make more sense
* OF_FAILED is a signed int.. fix return of of_address_cells
* OF_FAILED is a signed int.. fix return of of_size_cells


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42497 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-07-26 15:09:18 +00:00
Alexander von Gluck IV
ed8b50f79a small tab fix; no functional change
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42490 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-07-25 22:52:00 +00:00
Alexander von Gluck IV
d24ddec4e4 * Move platform support.cpp into less generic of_support.cpp
* Add header file to support of_support.cpp
* Add support functions to obtain address and size cell lengths
* Small style cleanups
* Add support for G5 PowerPC cpus...
* Refactor memory region code to be aware of 64-bit OF addresses.
  As-is the boot loader wouldn't start on G5 systems because
  OpenFirmware memory base addresses are stored as two 32-bit
  unsigned int 'cells' vs one 32-bit unsigned int 'cell' on G3/G4.
  I removed the static struct and replaced it with a template
  and pass uint32 or uint64 depending on the address cell size.
  Thanks for the idea DeadYak!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42486 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-07-25 22:26:35 +00:00
Alexander von Gluck IV
75f0db355c * Remove a few superfluous spaces
* Style fixes as per Axel
* Reintroduce removed OF_FAIL checks


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42460 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-07-21 01:44:45 +00:00
Alexander von Gluck IV
372fe617b2 * Clean up OpenFirmware machine detections
* Detect OpenBIOS used in QEMU and set machine flag
  (OpenBIOS isn't 1:1 Apple OpenFirmware)
* Show at boot which machine type is detected


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42459 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-07-20 20:31:32 +00:00
Alexander von Gluck IV
a1a978ff21 * Clean up translation debug output
* Few small style cleanups
* No functional change


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42458 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-07-20 17:06:13 +00:00
Alexander von Gluck IV
2e3b6c53ad * Clean up debugging of PowerPC mmu code to be consistent
* Clean up messge and error text
* Begin use B_PRI* macros


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42449 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-07-19 04:20:38 +00:00
Ingo Weinhold
1e393751ba MemoryManager::_GetChunks(): Fixed incorrect check. The area structure offset
introduced in r37701 was not taken into account for computing the short meta
chunk size. Fixes the reopened #6237.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42385 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-07-06 20:23:42 +00:00
Michael Lotz
961a96a987 Optimize the configuration of the port heap. Previously the max bin size was
512 bytes with a heap page of 2048 bytes resulting in excessive waste for
allocations between 512 and 1023 bytes. Also tune the requested alignment so
that sizeof(port_message) (currently 28 bytes) can occupy one allocation unit
without waste.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42340 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-29 18:03:42 +00:00
Michael Lotz
02cd58f418 Move resizing the page_protections before resizing the cache to avoid a needless
resize operation that has to be undone and may fail when doing so.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42332 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-28 00:15:12 +00:00
Michael Lotz
3fb17998a7 When resizing an area that has individual page protections (set via mprotect),
we have to enlarge/shrink the array that holds them and assign a protection
value for the additional pages as necessary. Otherwise we'll access invalid
memory when looking up page protections for enlarged areas and get random
protection values.
Experienced with QEMU that sets page protections via mprotect on heap memory.
When the heap was later enlarged, write access to the additional memory would
result in permission denied errors and crashes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42330 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-27 23:24:17 +00:00
Michael Lotz
14c345e147 * Revert r42319 as it introduces a race condition when entering the kernel
debugger. As sInDebugger is already > 0 when the first CPU enters KDL, code
  from other CPUs might see debug_debugger_running() == true already before they
  enter the debugger.
* Instead, move the sDebuggerOnCPU setting out of the debugger loop and hold the
  value until after calling exit_kernel_debugger() so that the exit hooks still
  see debug_debugger_running() == true.
* Also avoid calling exit_kernel_debugger() when we've been called recursively
  (previousCPU != -1). Previously the exit hooks would've been called and the
  debugger state reset erroneously. To balance the missing decrement of
  sInDebugger in that case we decrement sInDebugger in enter_kernel_debugger()
  also when detecting the recursion case.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42320 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-26 00:06:52 +00:00
Michael Lotz
3214710036 Use sInDebugger instead of sDebuggerOnCPU to determine if the debugger is
running. The former has a broader scope and lasts until the debugger exit is
actually done whereas the latter is already reset when the inner loop is exited.
This fixes the issue Ingo saw where the USB physical memory manager wasn't able
to free resources used for the debug transfer. It has reserved debug memory that
it uses depending on debug_debugger_running() and was therefore confused when
it returned false when called from the kernel debugger module exit hook.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42319 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-25 22:48:38 +00:00
Michael Lotz
4a3d2e7808 Make the heap debug functions available when USE_SLAB_ALLOCATOR_FOR_MALLOC is
enabled as well. As this heap implementation is still used for the port heap
(as it handles B_NO_LOCK areas) those are still useful.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42278 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-21 20:25:49 +00:00
Michael Lotz
6244ea5051 Fix range check. The previous check would produce an off by one error making the
last byte of an unmapped-but-still-there page non-readable (i.e. from B_NO_LOCK
areas), causing such reads to fail in KDL.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42276 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-21 13:06:26 +00:00
Michael Lotz
2b86134925 * Actually include an offset to write to in writev_port_etc(). It would
previously just always write over the beginning of the buffer for each vector.
  Since the writev version isn't exposed to userland by means of a syscall and
  kernel internally nobody used it, nobody noticed so far.
* Merge the two loops for user and kernel copy to remove the code duplication.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42273 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-21 01:13:43 +00:00
Michael Lotz
cd3e02ca1e * Growing the port heap by adding new areas was broken in various ways. For one
the acquired quota in sTotalSpaceInUse wasn't released in all cases leading to
  it eventually reaching the limit (after a _very_ long time though, so this is
  more theoretical than anything else). The sAllocatingArea flag wasn't reset in
  the case that an area was already added in the meantime, resulting in no
  further growing being possible. Then there were race conditions between
  waiting for space to become available and the situations which made that space
  available (freeing port_messages and adding new areas).
* Fix these race conditions by using a mutex (sPortQuotaLock) to protect the
  various quota and allocation related variables. Instead removed the atomic_*
  operations that were previously used.
* Had to move some static functions around.

Should make port heap growing more robust, even though in normal use you'll
likely never encounter it...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42272 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-21 00:56:20 +00:00
Jérôme Duval
11977ba83b added more cpu feature flags for x86
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42263 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-20 17:00:50 +00:00
Michael Lotz
71b9d8cf3b Check for the (local) APIC feature on the CPU before moving on to SMP config and
APIC enumeration. As the local APIC is the basis for inter-CPU communication, we
can't do SMP when it's absent.
Fixes #7692, but indeed it makes no real sense for QEMU to provide the APIC info
in the MP and ACPI tables (and actually emulate the hardware) when it disables
the APIC support flag at the same time.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42215 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-16 22:36:22 +00:00
Ingo Weinhold
100541ec40 waitpid(): Fixed regression introduced with my signals changes: When WNOHANG was
specified the syscall error code B_WOULD_BLOCK would no longer be mapped to 0.
Fixes #7693.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42188 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-15 02:42:53 +00:00
Ingo Weinhold
38c1f44d70 load_image_internal(): Forgot to reserve room on the stack for the program
arguments and environment. Fixes failures to start programs in case the space
available through rounding to full page sizes wasn't sufficient.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42184 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-14 13:39:54 +00:00
Ingo Weinhold
9437559db1 * Added function team_init_exit_info_on_error() which initializes the team's
exit info with some generic status.
* team_create_thread_start(), common_thread_entry(): Initializes the team's
  exit info (if that's the main thread) before calling thread_exit(). Fixes
  #7686.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42183 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-14 13:04:31 +00:00
Ingo Weinhold
dc3ba981d4 Added try_acquire_spinlock().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42180 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-14 12:41:11 +00:00
Ingo Weinhold
aa08883069 Use a more portable cast.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42173 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-14 11:23:48 +00:00
Stefano Ceccherini
4b2adaae5f Changed wrong help text
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42172 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-14 07:52:27 +00:00
Michael Lotz
75a4759d33 Since the c_ispeed and c_ospeed fields are marked unused, and since I don't see
how one could actually apply different speeds, make cf{set|get}{i|o}speed() use
the c_cflag field with the CBAUD mask instead.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42160 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-13 23:58:26 +00:00
Ingo Weinhold
0a187107e7 arch_debug_serial_[try_]getchar(): Look at the line status we read a bit closer
before assuming we have data. If the I/O port isn't valid (e.g. because there
is no serial port) 0xff seems to be a typical value to read. In that case fail.
Fixes KDL input on machines without serial port -- kgetc() would always think
it read something from the serial port, never trying any other input.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42153 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-13 18:25:08 +00:00
Ingo Weinhold
e823d4a6be Small refactoring: Moved serial port initialization to helper function.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42150 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-13 17:35:37 +00:00
Ingo Weinhold
90ade5e298 * Added file_system_module_info::uninitialize() analogously to
partition_module_info::uninitialize().
* Implemented the hook for BFS.
* Implemented KFileSystem::Uninitialize().

Fixes failure to initialize a BFS initialized device with an intel partition
map.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42142 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-13 01:53:11 +00:00
Ingo Weinhold
0b7fe5cbe2 partition_module_info::uninitialize(): Added block size parameter for
convenience.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42141 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-13 01:38:03 +00:00
Ingo Weinhold
285f4cf441 * Added optional partition_module_info::uninitialize() hook. It is supposed to
destroy the partitioning system's on-disk structure.
* Adjusted the existing partitioning system implementations accordingly.
  Actually implemented the hook for the intel partitioning system.
* Added Uninitialize() method to KDiskSystem and KPartitioningSystem. The latter
  implements the method calling the new module hook.
* _user_uninitialize_partition(): Also let the disk system uninitialize the
  on-disk structure.

This fixes the failure to initialize a disk device with BFS, when it contains a
valid partition map with at least one partition.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42140 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-13 01:27:13 +00:00
Ingo Weinhold
f84387d6c4 _user_initialize_partition(): After performing the operation don't set the new
disk system, if the partition already has a disk system set. This can happen
when the disk system's initialization function is lazy and just lets the DDM
rescan the partition. In bad cases the previous disk system has a higher
priority than the new one and, if its on-disk structures have not been
destroyed, it will win the rescan. Not setting the disk system in such cases at
least leaves the partition object in a consistent state.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42139 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-13 00:35:49 +00:00
Ingo Weinhold
ec623acad8 Removed weird debug output.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42138 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-13 00:21:30 +00:00
Ingo Weinhold
5e78920c12 * Added platform_debug_get_log_buffer() which returns the debug log buffer and
its size.
* Added "Display current boot loader log" item to the "Debug Options" boot
  loader menu. It displays what the boot loader has logged so far. Might be
  interesting for early boot issues when serial debugging is not possible.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42134 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-12 23:31:57 +00:00