Commit Graph

4857 Commits

Author SHA1 Message Date
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
Rene Gollent
73df2f2086 * Add validation of the RSDP checksums.
* If we detect ACPI 2.0 or higher, the spec says we should use the XSDT rather
  than the RSDT. Attempt to do so, falling back to the RSDT if the former fails
  to be mapped/validated.
* Refactored acpi_find_table into a templated version to account for the fact
  that the XSDT exports different pointer widths for its links to other tables
  than the RSDT.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42133 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-12 22:01:43 +00:00
Rene Gollent
36dc99a323 Add private get_memory_properties() syscall which allows one to retrieve the
address protection bits as well as the wiring flags for an arbitrary address
in a team's address space. Will be used in the debugger for the purposes
of the memory inspector/editor, in order to determine whether it can in fact
allow editing for the currently inspected address range.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42129 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-12 20:17:14 +00:00
Ingo Weinhold
8bcc50c336 * Added arch_debug_blue_screen_try_getchar() and arch_debug_serial_try_getchar()
which don't wait for a character, but return -1 when no character is
  available ATM. Implemented correctly for x86 only.
* Changed the semantics of the debugger_module_info::debugger_getchar() hook.
  It is supposed to return immediately now.
* Adjusted usb_keyboard accordingly. Hacked UHCI's debug_process_transfer() to
  achieve that. It does now start, check, or cancel a transfer. Split
  UHCI::ProcessDebugTransfer() into StartDebugTransfer(), and
  CheckDebugTransfer() accordingly, and also added a CancelDebugTransfer().
  The latter seems to have issues. Michael, please have a look. I have no clue
  what I'm doing. :-)
* Adjusted kgetc() to poll all possible inputs using the new
  functions/semantics. This allows to use any input (USB, PS/2, serial) in KDL.
* Removed the no longer needed "serial_input" command.
* read_line(): Also support 0x7f as backspace code. That's what xterm sends.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42126 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-12 17:15:42 +00:00
Ingo Weinhold
b23ab34f66 I accidentally committed r42122 and r42123 to the signals branch. Merged into
trunk. The interesting part of r42122 was already fixed in the trunk, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42124 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-12 14:53:02 +00:00
Rene Gollent
c4b692da1a Revert r42105. The rsdt_length field on the rsdp structure we have declared is
actually misleading, since it specifies the length of the xsdt rather than the rsdt. Furthermore, it is only available if the BIOS reports ACPI version 2.0 or greater. Since we don't currently support the XSDT, we can't rely on that field and have to resort to the previous approach of mapping the RSDT header in order to determine the length of the RSDT itself.

Also add validation of the RSDT's checksum so we don't get tripped up by BIOS's with broken tables.

Should fix boot problems that were introduced by r42105.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42118 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-12 01:56:29 +00:00
Ingo Weinhold
24df65921b Merged signals-merge branch into trunk with the following changes:
* Reorganized the kernel locking related to threads and teams.
* We now discriminate correctly between process and thread signals. Signal
  handlers have been moved to teams. Fixes #5679.
* Implemented real-time signal support, including signal queuing, SA_SIGINFO
  support, sigqueue(), sigwaitinfo(), sigtimedwait(), waitid(), and the addition
  of the real-time signal range. Closes #1935 and #2695.
* Gave SIGBUS a separate signal number. Fixes #6704.
* Implemented <time.h> clock and timer support, and fixed/completed alarm() and
  [set]itimer(). Closes #5682.
* Implemented support for thread cancellation. Closes #5686.
* Moved send_signal() from <signal.h> to <OS.h>. Fixes #7554.
* Lots over smaller more or less related changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42116 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-12 00:00:23 +00:00
jackburton
14282c1e55 We already know the rsdt length in advance,
so map the whole table without freeing and remapping later


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42105 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-11 19:54:56 +00:00
anevilyak
6e70e32dec If we found a header, but it wasn't the one we were looking for, reset the header ptr to NULL after unmapping. Otherwise a bogus header pointer was potentially returned, leading to an invalid mem access. Fixes boot problems on my Athlon following recent ACPI changes.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42103 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-11 18:38:15 +00:00
Ingo Weinhold
2e8aa19c63 * The boot loader does now set up an IDT that allows it to catch processor
exceptions (page faults and the like). The handler dumps possibly interesting
  information (registers, a (numerical) stack trace) to the serial output, and,
  if possible, also to the screen. That should help debugging boot loader
  crashes.
* For the IDT the boot loader sets up for the kernel the descriptors are set up
  the same way, so until the kernel initializes the IDT itself (arch_init()) the
  facility is still in place and can thus catch very early kernel boot crashes.
  Unfortunately the on-screen output doesn't seem to work anymore at that point,
  so the output only goes to the serial port...
* ... and to the debug syslog -- dprintf() does now append it there after
  debug_cleanup() has been called. Seems to work fine in qemu, but when I tested
  it on real hardware the debug syslog was gone.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42092 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-11 00:08:42 +00:00
Stefano Ceccherini
b047e41327 Map the whole table also in acpi_check_rsdt().
Also print the table revision, after the vendor.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42084 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-10 12:59:14 +00:00
Stefano Ceccherini
fb764e7fda Map the whole table, and not just the header. Fix #7497 again (hopefully
correctly now)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42083 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-10 10:34:41 +00:00
Stefano Ceccherini
ad12a198d7 Revert r42068 and r42069, since they didnt' make sense (but something's
obviously fishy)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42078 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-09 21:01:57 +00:00
Stefano Ceccherini
0a3e6ddf63 Add a comment so this doesn't happen anymore
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42069 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-09 15:01:35 +00:00
Stefano Ceccherini
e282383b4e Map B_PAGE_SIZE, and not just acpi_description_header (was actually a
regression), since the tables are bigger than that.
Accessing unmapped memory was doing bad things on
XenServer.
Fixes ticket #7497.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42068 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-09 14:52:56 +00:00
Stefano Ceccherini
5cea82988c Missing default case
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42067 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-09 14:44:43 +00:00
Ingo Weinhold
dfc8551aad open_executable(): Changed search order according to the ABI specs. DT_RPATH
is now searched before the LIBRARY_PATH/ADDON_PATH. Fixes #7638.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41903 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-04 13:28:31 +00:00
Ingo Weinhold
9536ec0297 Reimplemented the gdb stub support for the 'g' command (read registers):
* Added an arch_debug_gdb_get_registers() interface that is supposed to provide
  the register values in the format expected by gdb and implemented it for x86.
* Reimplemented gdb_regreply() to use that. Also made it buffer overflow safe.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41880 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-06-03 15:35:10 +00:00
Jérôme Duval
6ec9dff3f3 ppc build fix
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41834 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-30 19:51:45 +00:00
Ingo Weinhold
ad63c6796c Improved debug output.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41833 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-30 18:48:10 +00:00
Michael Lotz
caa82f7074 * Don't try to check devices that are obviously not on PCI anymore.
* Fix a warning about pci_address::segment potentially being used uninitialized.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41760 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-26 18:05:50 +00:00
Michael Lotz
7ce4456927 * After reading the routing table(s), do another run through the PCI devices and
check if all of them are assigned with a routing entry. If not, as happens for
  PCI add-on cards that ACPI isn't aware of for example, infer the routing by
  calculating it from the PCI default routing and going up through the parents
  until a matching routing entry is found. Fixes #7520.
* This will also panic (for now) in case there remain unroutable devices and
  eventually will prevent the IO-APIC to be used in these cases.
* Enabled some debug output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41758 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-26 12:35:02 +00:00
Rene Gollent
e7d7b1e232 Add debug option to disable the on-screen debug output's paging by default, for
cases such as USB keyboards where the keyboard no longer functions once the 
kernel is entered and the USB stack initializes.

Implements #7561.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41736 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-25 02:56:46 +00:00
Michael Lotz
cb80e931f6 * Turn around finding the routing table on a PCI bridge and checking for it to
actually be a bridge. We always want to check if the device at hand is a PCI
  bridge, because in that case we need to recurse further down. We recurse now
  even if there is no routing table found for the current bridge, since that
  doesn't mean that another bridge, further below, can't have a routing table
  again. Possibly fixes #7520.
* Fix the matching function to just check for function 0 to be present instead
  of classifying it. Previously if there happened to be a cardbus bridge on
  function 0 of a multi function device, the rest of the functions of the device
  would've been ignored because we returned early due to the unsupported bridge.
* Only hand down the current bus number when recursing as that makes it clearer
  what's going on instead of handing in a partially filled out pci_address
  structure and then filling in other parts inside the function.
* Commented out getting the segment number as we don't support it at all.
* Extended debug output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41726 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-25 00:11:33 +00:00
Rene Gollent
e26b9867f0 Build fix, removed one line too many.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41708 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-24 12:34:05 +00:00
Rene Gollent
5e3eb88b1c Cleanup: no need for parsing since the kernel settings will handle semicolon separated options directly. Thanks Axel!
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41707 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-24 12:10:57 +00:00
Rene Gollent
8837310ce7 * Slightly alter the semantics of the input gathering function to take the
menu item it's associated with rather than an input string. This allows it
  to calculate the position to start the input at, as well as the correct
  line to place it on. The previous solution always put the input at the
  center line, which happened to be the right place by happy coincidence
  unless one also had the menu items for viewing/saving the debug syslog
  present.
* Implement input buffer scrolling, and consequently lift the previous size
  limit on user input (it is now only limited by the size of the passed in
  buffer).
* Implement parsing of the input buffer to allow it to handle comma-separated
  options. Thus, one can now input things like "disable_smp true, serial_debug_output false"
  and it will be handled properly.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41706 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-24 03:21:51 +00:00
Michael Lotz
2c0d5258df Of course the PIC mask register is a _mask_ and the enabled interrupts are the
ones that aren't masked. This reversed the enabled interrupts and therefore
disabled the already installed ACPI SCI handler and wrongly enabled the other
interrupt pins instead on PIC to IO-APIC handover. Probably fixes #7525.
+r1alpha3


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41685 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-23 18:01:59 +00:00
Michael Lotz
f599932f82 * Simplify APIC writes.
* Add explicit volatile keyword.
* Minor variable name cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41684 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-23 15:02:05 +00:00
Michael Lotz
2ae3d5121c Switch to using the PIT in mode 0 (interrupt on 0) instead of mode 2 (rate
generator). There are chipsets (namely ATI/AMD SBx00) where mode 2 doesn't seem
to work (the counter isn't reloaded after the countdown has completed). Mode 0
has the same resolution as mode 2 and, as interrupts are disabled at this point
in booting, is otherwise equivalent as well. I've tested this on 5 machines
available to me and it doesn't seem to have any negative effect.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41683 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-23 14:51:42 +00:00
Michael Lotz
7adc7269d8 * Re-program the timer for each loop instead of waiting for it to wrap around.
With that we will usually start right away without having to wait for the
  timer to be in the desired state, which removes roughly 116ms of spinning
  around for a normal calibration run.
* Read back the value once after programming. The delay this introduces
  accounts for the fact that the counter will only start counting down on the
  next clock cycle.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41680 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-23 13:25:44 +00:00
Michael Lotz
2d62c17d26 * Add a limit to how often we retry the calibration. It's there as an upper
bound to prevent spinning forever if we have a very unstable TSC that we
  simply can't calibrate. Shouldn't really happen though.
* Set the gate low for channel 2 on exit if we used it as the counter.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41678 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-23 12:36:43 +00:00
Michael Lotz
34d3f13c64 * Put the calibration loop into a static inline function and replace the three
copies of it with a call to that.
* Make the variable names more readable and spacing cleanup.

No functional change intended.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41670 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-23 11:15:51 +00:00
Michael Lotz
d620303480 * Use macros to make the PIT programming more readable. Yes, I know that the PIT
timer code has such definitions too, but they're not quite as verbose. Will
  eventually make the latter use these too.
* Prepare for possibly using other PIT channels for the calibration. Right now
  everything's the same still.
* Add disabled print of the resulting factors.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41669 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-23 10:33:10 +00:00
Michael Lotz
cb4e75d3eb * When configuring a link device failed, fall back and keep the currently
active config and update the info for the remaining shared link device
  entries. Seen on KVM for the (PCI) ACPI interrupt, but happens where there is
  no _SRS method for a device (as this one is optional). I find that a bit
  strange however as in such a case no _PRS (possible resources) should be
  present either, especially not one advertising a config different from the
  current one.
* Print the routing table later, after enabling irq routing, so that possible
  changes due to such a fallback are included.
* Fix a typo.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41652 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-22 12:06:17 +00:00
François Revol
76b93c655d Fix the Amiga bootloader build.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41600 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-19 23:08:03 +00:00
Rene Gollent
93e483aeab Another build fix...need coffee.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41580 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-19 12:08:13 +00:00
Rene Gollent
b4aa5d34cf Build fixes.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41578 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-19 03:33:56 +00:00
Rene Gollent
d2b49a0031 * Implement support for user input of additional safe mode options that
aren't otherwise exposed via the safe mode menus. The option can be 
found under the debug options menu, where additional settings can be 
added one at a time with the same syntax used in kernel settings files 
(i.e. disable_acpi on). 

Scrolling of the input buffer is not yet supported (will implement that 
soon), so currently the input is clamped to the size of one line. This 
shouldn't be a problem for our current set of options though.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41577 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-19 01:38:02 +00:00
Rene Gollent
13fd92e6a0 Update boot loader copyright year. Resolves #7515.
+alpha3



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41574 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-18 23:10:23 +00:00
Ingo Weinhold
222b8cf7b7 cache_io(): Since satisfy_cache_io() (respectively the function it calls)
unlocks the cache, we have to look up the page again, since someone else could
have removed it in the meantime. Possibly fixes #7514.

+r1alpha3


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41564 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-18 10:13:44 +00:00
Michael Lotz
aa373c439f We have to decouple the enumeration and marking of the NMIs from the actual NMI
pin configuration as the configuration only happens after preparing the
configuration where we already need the NMI mask.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41536 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-16 14:59:25 +00:00
Michael Lotz
74e9ede3b2 Simplify and clean up. Removed most of the shifts and made direct masks out of
the macros. This makes things more readable and also fixes the few remaining
80 char limit violations. No functional change intended.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41533 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-16 14:32:01 +00:00
Michael Lotz
bc409b4915 Fix minor debug output oversight in the last commit.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41532 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-16 14:11:24 +00:00
Michael Lotz
9ae3fdcb02 * Move redirection entry configuration into a separate function and allow to
specify the delivery mode.
* Use that function from ioapic_configure_io_interrupt() and use it when
  configuring NMI sources to actually set the entries to NMI.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41531 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-16 14:06:27 +00:00
Michael Lotz
86d59c04c6 Support NMI sources. Any non maskable interrupt (NMI) will be marked as
unavailable for routing so that we don't end up configuring anything on them.
I haven't seen these in actual use though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41530 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-16 13:36:31 +00:00
Michael Lotz
22d72c8ee1 Guard against IO-APICs with too many entries. We only support 64 entries because
we use a 64 bit level triggered mask. In practice these don't exist as far as I
know. If we encounter them at a later stage we need to revisit the mask.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41529 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-16 13:25:45 +00:00
Michael Lotz
fb5a1727f4 * Implement interrupt source overrides. We install a relay interrupt handler
at the override entry to trigger the overriden vector so that we don't need
  to configure any additional redirections.
* Also configures the polarity and trigger modes found in the override entry.
* When disabling the legacy PIC, retrieve the enabled interrupts and re-enable
  then in the IO-APIC. This will for example make the ACPI SCI work that is
  installed prior to switching interrupt models. Through the transparent support
  for interrupt source overrides it'll also automatically relay from the old to
  the new vector.

This should make ACPI interrupts work and should support relocating the ISA PIT
from irq 0 to a different global system interrupt (usually 2) so that it can
still work when IO-APICs are in use.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41528 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-16 12:57:40 +00:00
Michael Lotz
9c1714ec1a Enable IO-APICs by default. It's been tested on a broad spectrum of hardware and
all reports so far have been positive. We fall back to legacy mode in the cases
where we can't figure out the correct routing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41527 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-16 08:42:30 +00:00
Oliver Tappe
6a5ce30120 Move functions declared in private/system/system_info.h out of the public namespace.
* prepend private functions get_system_info_etc(), start_watching_system() and 
  stop_watching_system() with '__'
* adjust callers accordingly


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41517 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-15 17:02:36 +00:00
Oliver Tappe
22a7fe9695 Cleanup system-revision stuff.
* move system_revision.h to headers/private/libroot
* unify libroot's get_system_revision() (the one I introduced recently) with kernel's
  get_haiku_revision(), the function is now called get_haiku_revision() in the kernel
  and __get_haiku_revision() in libroot
* system_revision.c is now being built as part of libroot and as part of the kernel
* adjusted all callers of get_system_revision() accordingly


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41516 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-15 16:33:30 +00:00
Michael Lotz
e64bb27712 Fix another oversight of r41500. The size check was using sizeof(char *) instead
of bufferSize, corrupting entries when multiple items within the same menu were
checked.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41505 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-14 23:22:35 +00:00
Michael Lotz
192bc027ea Disabling the local APIC also means disabling SMP, as the APIC is the base for
all inter-CPU messaging. The previously described timekeeping is just an extra
function of local APICs. Before, if you'd select "disable local APIC" it would
still blindly write to invalid memory (targetting the non-mapped local APIC) and
then just hang waiting for the other CPUs (that were obviously not responding
to the init sequence that wasn't programmed).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41504 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-14 23:09:18 +00:00
Michael Lotz
ba0c232abb Fix typo that caused the (first) IO-APIC address not to be set anymore when
configuring SMP via MP tables. We don't support that method anyhow, but it
should still report correctly.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41503 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-14 22:37:26 +00:00
Rene Gollent
469cccb22c Fix small error in previous commit that resulted in the fix not working as intended.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41501 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-14 21:12:07 +00:00
Rene Gollent
e21407d07b When applying settings from the boot menus, aggregate them and then add them
to the kernel args in a single go. Otherwise we wind up with more link list
entries than expected, which in turn resulted in settings not quite being
parsed properly upon entering the kernel, which meant that if options were
chosen in both the debug and safe mode menus, only the debug ones were
applied. This might also have resulted in the kernel settings not being
loaded correctly in such an instance.

Should fix various issues people have had with safe mode settings not being
applied properly.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41500 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-14 20:37:37 +00:00
Oliver Tappe
a961bbc69d * move sHaikuRevision from uname.c into new system_revision.c
* add private function get_system_revision() for accessing the
  revision string
* adjust uname to use get_system_revision

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41479 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-13 20:38:14 +00:00
Michael Lotz
8908aef9c2 * Don't map the IO-APIC within the bootloader. We don't need it to set up SMP
at all and, since there can be multiple IO-APICs, we need to do the
  enumeration again in the kernel anyway. Also only set ioapic_phys the first
  time we encounter an IO-APIC object as it looks cleaner when we arrive at the
  first IO-APIC default address.
* Therefore we don't have to worry about already mapped IO-APICs when
  enumerating them in the kernel.
* Also remove the mapping function that is now not used anymore.
* We still use the ioapic_phys field of the kernel args to determine whether
  there is an IO-APIC at all to avoid needlessly doing the enumeration again.

This fixes multi IO-APIC configurations, because before we would indeed map
the last IO-APIC listed in the MADT, but then in the kernel assumed we mapped
the first one. We'd end up with mapping the last listed IO-APIC twice and the
first IO-APIC never, always programming the last one when we actually targetted
the first one.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41476 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-13 16:31:31 +00:00
Michael Lotz
0798779a2f Resolve TODO: Take the writing order into account. Ensure the mask bit is
written first/last depending on the operation to avoid modifying entries that
are still unmasked or unmasking entries that aren't set up yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41457 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-12 00:11:34 +00:00
Michael Lotz
f91cbdde46 Better watch those 1s. These are actually signed 32 bit values, so they will
have unexpected side effects once we shift them more than 30 bits.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41452 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-11 23:38:06 +00:00
Michael Lotz
ca00b28e8b Fix another case where the local interrupt vector would be added instead of the
global system one.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41451 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-11 23:17:12 +00:00
Michael Lotz
0414a20330 Print some more MADT entries when debug output is enabled. Right now they are
informational only, but most of these entries actually need to be handled.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41450 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-11 23:14:02 +00:00
Michael Lotz
6347525607 * Always retrieve the APIC ID from the descriptors.
* Actually program the IO-APIC ID when configuring the IO-APIC.
* Moved some debug output around.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41447 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-11 19:55:56 +00:00
Ingo Weinhold
5e36c12a42 mmu_allocate_physical(): The wrong base argument was passed to
get_free_physical_address_range(). Fixes the debug syslog feature.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41446 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-11 19:10:26 +00:00
Michael Lotz
a56cbb2afb * When initializing MSI support, don't assume a single 24 entry IO-APIC. Instead
mark the ISA interrupts as unusable and then use ioapic_is_interrupt_available
  to determine if that vector is possibly taken by an IO-APIC. If IO-APICs are
  not used, this will simply always return false, leaving all vectors free for
  MSI use.
* The msi_init() now has to be done after a potential IO-APIC init, so it is now
  done after ioapic_init() instead of inside apic_init().
* Add apic_disable_local_ints() to clear the local ints on the local APIC once
  we are in APIC mode (i.e. the IO-APIC is set up and we don't need the external
  routing anymore).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41445 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-11 18:05:05 +00:00
Michael Lotz
0f91697fd7 Fix previous commit and add printing APIC id fields.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41437 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-11 11:24:15 +00:00
Michael Lotz
cdb247a328 Extended and fix some of the debug output.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41436 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-11 11:16:10 +00:00
Michael Lotz
7a8ce431b5 Obviously we want to use the GSI as interrupt vector as well...
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41435 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-11 09:49:51 +00:00
Michael Lotz
e9d5569740 Only make GSI 0 into an ExtInt and GSIs 1-15 ISA interrupts. When having
multiple IO-APICs every IO-APIC was initialized to the standard mapping before.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41434 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-11 09:13:21 +00:00
Michael Lotz
ca67ddb353 When enumerating IO-APICs failed, try to still get the routing done with how far
we got. If the routing is possible with the limited IO-APICs everythings good,
if not we will simply fail at the routing preparation stage where we can still
fall back gracefully. This makes things a bit more error resilient.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41432 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-11 09:01:50 +00:00
Michael Lotz
eda743903e Provide an interrupt availability check callback instead of a maximum IRQ
number. This accounts for possible gaps in the IO-APIC GSI mappings. Since most
of the time there will be only a single IO-APIC the extra overhead is relatively
small.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41431 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-11 08:47:56 +00:00
Michael Lotz
d11e32a807 Enumerate IO-APICs using the ACPI Multiple APIC Descriptor Table (MADT). We do
the same for the first IO-APIC in the bootloader (also using the MADT), but
here we can use the ACPI module. The enumerated IO-APICs are added to the list
and should be usable from there on. For lack of hardware I wasn't able to really
test that though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41430 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-11 08:27:03 +00:00
Michael Lotz
5d01e61a91 * Prepared everything to eventually support multiple IO-APICs.
* Added some TODOs regarding register write order that might have bad side
  effects.
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41428 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-11 02:50:36 +00:00
Michael Lotz
dc14d97b7f * Move the legacy PIC and the IO-APIC code into their own source file. No
functional change intended.
* Use an appropriately sized sLevelTriggeredInterrupts for each controller type.
  This also fixes an out of bound access for IO-APICs with more than 32 entries
  and also returns the right mode in such cases.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41426 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-11 00:53:03 +00:00
Michael Lotz
393b3b70a7 Fix build with TRACEs on.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41422 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-10 18:47:11 +00:00
Oliver Tappe
af2da315dc Fix the larger problem that was hiding behind the build problem of set_haiku_revsion on FreeBSD:
* the length of the sHaikuRevision character array symbol needs to be set explicitly,
  as using either _SYS_NAMELEN or sizeof(utsname::version) will only return the values
  for the host, which may not match ours, thus potentially causing problems when using
  sHaikuRevision
* add headers/private/system_revision.h which defines SYSTEM_REVISION_LENGTH to 128
* adjust definitions of sHaikuRevision in libroot and kernel accordingly
utsname::version is shorter than SYSTEM_REVISION_LENGTH, but that doesn't cause any harm
until we have indeed switched to a DVCS (in which case longer revision strings will be 
cut off by 'uname').


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41421 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-10 15:35:04 +00:00
Michael Lotz
c7e314bba7 Use const references instead of pointers for the print functions.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41417 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-10 10:07:46 +00:00
Michael Lotz
9173e3843e * Choose the desired configuration of the link devices at preparation time
already. This allows to detect invalid settings before starting to enable
  IRQ routing and therefore allows to gracefully fall back to PIC mode on error.
* Actually read the number of IO-APIC entries before using that number in
  routing preparation.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41416 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-10 09:59:50 +00:00
Michael Lotz
ad1757252e Check hardwired and chosen IRQs against the maximum we can address. Try to fail
gracefully in such cases (resulting in the IO-APIC not being used).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41415 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-10 09:29:57 +00:00
Michael Lotz
414f205aee Remove the IRQ to IO-APIC pin mapping array. It isn't used as we don't redirect
vectors at all. It'd also not work for multi IO-APIC setups which we don't
support yet (but are relatively rare anyway).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41414 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-10 08:50:57 +00:00
Michael Lotz
3c4a8701d6 Remove comment that does no longer apply.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41413 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-10 07:31:55 +00:00
Michael Lotz
c5c4213aee Actually increase the usage counter by the amount of devices behind the link
device as it may have multiple devices routed to it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41402 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-09 16:49:17 +00:00
Michael Lotz
80c4e0ced0 * Balance the IRQs amongst the possible ones. A simple usage counter, filled by
hardwired GSIs and updated on configuring the link devices, is used for that.
  This doesn't guarantee optimal results as some link devices may not be
  configurable to some IRQs and we might fill up their slots this way. Most of
  the time this should be good enough though.
* Take the BIOS assigned IRQ white list into account when assigning IRQs in the
  ISA range and avoid assigning to non white listed IRQs. Quite probably it'd be
  ok to use all of the IRQs present in the possible IRQ list, but let's play it
  safe...
* Also white listed are the IRQs that were set on the link device before
  reconfiguration.
* Some cleanup, use references instead of pointers where applicable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41401 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-05-09 16:46:18 +00:00