Commit Graph

343 Commits

Author SHA1 Message Date
Ingo Weinhold
71848dd62f arch_elf.c -> arch_elf.cpp
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15910 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-11 14:26:15 +00:00
Ingo Weinhold
b33f1804ea Faster/shorter way of aligning something.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15909 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-11 14:14:50 +00:00
Ingo Weinhold
b7ba8a182f We enable the FPU now, store the non-volatile FPU registers on
context switches and all FPU registers in an iframe. We might want
to rethink this, though.
The kernel initialization runs to the end now. No boot volume is
found yet, but that is expected.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15908 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-11 13:51:38 +00:00
Ingo Weinhold
9b6eaae234 * Fixed thread support. The entry and exist functions are now called,
too -- introduced a function ppc_kernel_thread_root() which calls the
  three functions (entry, start, exit) in sequence. This brings us well
  into the second part of the kernel initialization.
* Replaced stmw/lmw in ppc_context_switch() by individual stwu/lwzu
  sequences. The former ones are documented to perform suboptimal on
  some architecture implementations.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15904 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-11 02:17:29 +00:00
Ingo Weinhold
31ac264b1e Added TODO regarding the use of arch_cpu_global_TLB_invalidate().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15903 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-11 02:05:29 +00:00
Ingo Weinhold
d0648592ca It appears I misjudged the availability of the "tlbia" instruction. Put
the previous implementation of arch_cpu_global_TLB_invalidate() back in
place (as fallback).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15902 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-11 01:31:15 +00:00
Ingo Weinhold
6c678c57c7 * The exception vector offset is now also part of the iframe.
* Cloned iframe stack management from x86.
* Reimplemented arch_thread_{get,set}_current_thread(). The
  thread structure is stored in SPRG2. It is set to NULL in
  arch_cpu_preboot_init(), now. A non-null current thread
  causes all kinds of undesired behavior in early boot code.
* We establish the address space mappings we know from the
  Open Firmware as areas. At least those in kernel address
  space. The ones in userland address space are tougher.
  Fortunately on my Mac mini there aren't any save the
  boot_loader stack, which is not needed any longer anyway.
* Added stack trace support to the kernel debugger. Mostly
  cloned and adjusted the x86 code. Some bits are still
  missing, like stack traces for other threads.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15890 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-10 03:00:33 +00:00
Ingo Weinhold
1777154c14 * Fixed tracing build.
* In reserve_boot_loader_ranges() we skip ranges that lie without
  the kernel address space (we failed and panic()ed before). The
  architecture specific code has to deal with those, if they are
  of any importance.
* sAvailableMemoryLock.sem was not set to -1 in vm_init() so code
  executed after semaphores were available but before the semaphore
  was created caused semaphore 0 to be acquired.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15889 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-10 02:22:24 +00:00
Ingo Weinhold
e2f7a6d61f Missed that one.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15883 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-09 03:42:39 +00:00
Ingo Weinhold
48fe700d70 arch_debug.c -> arch_debug.cpp
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15882 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-09 03:38:09 +00:00
Ingo Weinhold
7176dd57e5 Reworked the exception handling code. The former one ran into the
void after turning off BAT for the segment containing itself.
The monster macro for the exception vector code was not really
elegant besides being too long for the 32 byte performance
monitor exception slot. Furthermore wasting three of the SPRG*
registers as cheap scratch memory wasn't that nice either.

We now have a three-step approach: The exception vectors
themselves contain only five instructions which branch to common
code at the beginning of the same physical page. That one sets
up BAT for itself, turns address translation back on and jumps
into the kernel. There we turn off BAT again, dump an iframe,
and enter the actual exception handler (/dispatcher). Upon return
the registers are restored from the iframe and we get back to the
place where the exception occurred.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15881 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-09 03:30:52 +00:00
Ingo Weinhold
a06cbf3fc2 arch_int.c -> arch_int.cpp.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15876 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-08 17:14:26 +00:00
Axel Dörfler
8c7229ddbe Fixed some GCC4 only warnings
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15865 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-08 12:39:06 +00:00
Ingo Weinhold
262e0a636b We use the same strategy for computing the system time as on x86 now.
The time base conversion factor is the 32 bit value
  2^32 * 1000000 / time base frequency,
so the system time can be computed by
  system time = time base * conversion factor / 2^32.
The expression in system_time() looks more complicated now, but is
actually much faster (factor 2.5 on my Mac mini). I'm positively
surprised, how good the assembly looks, that GCC 4 generates. There's
not that much potential for optimization by hand-coding the function.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15863 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-07 23:05:56 +00:00
Ingo Weinhold
8baf8813c0 Added "shutdown" debugger command. Implemented arch_cpu_shutdown() for
PPC.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15862 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-07 22:49:43 +00:00
Ingo Weinhold
85af525e59 * Added missing call to __ppc_setup_system_time(). system_time()
and real_time_clock[_usecs]() finally seem to work (at least in
  the kernel).
* Removed accidentially committed debug output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15861 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-07 20:35:13 +00:00
Ingo Weinhold
67ea83c566 We use the generic physical page mapper for PPC now. I realized that it
is actually not that nice for PPC since we don't have large pages.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15860 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-07 20:32:32 +00:00
Ingo Weinhold
3b36b30fef * Made vm_alloc_virtual_from_kernel_args() available to other kernel
parts, too. Fixed a potential overflow.
* The generic physical page mapper reserves the virtual address range
  for the IO space now, so that noone can interfere until an area has
  been created. The location of the IO space is no longer fixed; it
  didn't look to me like it was necessary for x86, and we definitely
  need to be flexible for PPC.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15855 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-07 17:37:21 +00:00
Ingo Weinhold
a71974c1f8 Pulled the algorithm for dynamically mapping physical pages into an
"IO space" out of the x86 specific source into arch/generic. We'll use
it for PPC as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15853 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-07 03:13:42 +00:00
Stefano Ceccherini
a041f6e8f6 Fixed a couple problems in the time keeping mechanism, which got broken lately. Done in tandem with Korli
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15846 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-05 16:03:22 +00:00
Ingo Weinhold
e55e1a0e66 Implemented the PPC specific RTC support. We search for an "rtc"
device in the Open Firmware implementation of boot loader and
pass its path to the kernel, where it's opened and used for
getting/setting the real time. The expensive atomic_*64() on PPC
32-bit make things a bit more complicated. Moreover, missing
64 bit multiplication and division instructions won't really
allow system_time() to be anywhere near as fast as on x86. :-/


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15837 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-04 04:55:04 +00:00
Ingo Weinhold
09bb4e9ac5 The real_time_data structure contains an architecture specific
substructure now (that's the only member actually). The system time
offset is therefore accessed via architecture specific accessor
functions.
Note, that this commit breaks the PPC build. Since I want to rename at
least one file I've already changed, I can't avoid that.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15835 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-04 02:17:59 +00:00
Ingo Weinhold
d9a5e6050f Pulled the conversion between seconds since the epoche and the split up
(year, month,...) representation out of the x86 specific code and put
respective support functions into real_time_clock.c. We'll need those
for the PPC specific part too.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15827 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-03 17:26:37 +00:00
Ingo Weinhold
27ceaeaccc Renamed arch_real_time_clock.c to arch_real_time_clock.cpp in
anticipation of the things to come. :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15825 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-03 16:34:41 +00:00
Ingo Weinhold
7afa713acb Reorganized the boot platform dependencies in the kernel a bit.
Basically the architecture specific code is now responsible to
init and make use of the platform specific code, now. The reason
being that we have only one kernel per platform and thus cannot
decide at compile time, which platform to use (if any).
The PPC implementation features an abstract base class PPCPlatform
(implemented for all supported platforms) through which platform
support is provided.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15824 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-03 16:26:39 +00:00
Ingo Weinhold
716a16ce61 * Find out a few interesting information about the system (like CPU,
bus, and time base frequency) in the PPC boot loader, and propagate
  them to the kernel via kernel_args.
* Now we use the correct time base frequency for timer calculations.
* Implemented PPC specific system info stuff. Added a few PPC CPU
  types to <OS.h>.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15817 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-03 13:30:23 +00:00
Axel Dörfler
37675ea580 Deleted ranges were never removed from the ranges hash... this could have finally
nailed down bug #77.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15791 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-02 13:09:42 +00:00
Ingo Weinhold
c8cd524c67 * Refactored arch_vm_translation_map_init_post_area() a bit: Pulled out
remapping stuff into separate functions and made them available to
  others.
* Remap the exception handler space in arch_int_init_post_vm() into the
  kernel address space (same issue as with the page table).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15783 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-02 03:30:58 +00:00
Ingo Weinhold
835fb10b16 Added of_exit and of_enter KDL commands.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15782 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-02 02:30:31 +00:00
Ingo Weinhold
10a83ac31f * Added tlbia() and tlbie() macros. Replaced ptesync() by ppc_sync();
the fact that I couldn't find ptesync in an otherwise more complete
  documentation I downloaded yesterday made me suspicious.
* arch_cpu_global_TLB_invalidate() uses tlbia now. The instruction is
  optional, but so is tlbie (how I understood it is that both exist,
  when the architecture implementation has a TLB). And the former loop
  looked just scary.
* Implemented arch_cpu_user_TLB_invalidate(). It does just the same as
  arch_cpu_global_TLB_invalidate().
* Some changes with respect to synchronization required on page table
  and segment register updates.
* Some more minor renaming. Pulled a new function
  remove_page_table_entry() out of unmap_tmap().
* In arch_vm_translation_map_init_post_area() we do now remap the page
  table into the kernel address space, if it was without before. The
  page table might actually be a good application for BAT, though.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15773 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-01 21:40:27 +00:00
Ingo Weinhold
b019d8c5f3 * Renamed the static variables according to Haiku conventions.
* Renamed occurrences of ASID/asid to VSID/vsid where appropriate.
* vm_translation_map_arch_info::vsid_base is now the first usable
  VSID and doesn't need to be shifted anymore.
* Changed the VSID base shift from 4 to 3, since we need only 8 VSIDs
  per team.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15772 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-01 16:15:04 +00:00
Ingo Weinhold
8761241015 * Fixed calculation of num_pages. It came out one too small.
* Fixed several off-by-one comparisons with num_pages.
* vm_alloc_virtual_from_kernel_args() now makes sure the allocated
  region lies within the kernel address space (or is at least
  >= KERNEL_BASE).
* Simplified one or two patches.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15771 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-01 15:23:31 +00:00
Ingo Weinhold
5b35f4211e Implemented arch_debug_serial_getchar(), so we can even type something in
KDL. :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15770 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-01 15:09:11 +00:00
Ingo Weinhold
b9b301b6c8 * Replace the arch_cpu_global_TLB_invalidate() sledge hammer in
fill_page_table_entry() by a ptesync(). Mapping the kernel heap
  took about 2 minutes here before.
* Added missing shift of the asid_base in ppc_translation_map_change_asid().
* Commented out the BAT stuff in arch_vm_translation_map_init_post_area().
  Besides that I think it won't work that way, it made the page table
  unaccessible; though I'm not sure why.
* Added a bit of documentation to the beginning of the file. Should give
  enough information to understand what happens here without further
  detailed knowledge about the architecture.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15769 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-01 15:07:53 +00:00
Axel Dörfler
e075b5a32e Added some debug helper. Hopefully they give more insight to Stephan's problem (bug #77/#78).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15767 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-31 14:31:31 +00:00
Ingo Weinhold
957a1b17eb * Introduced new build system variables
{HAIKU,HOST,TARGET}_KERNEL_PIC_{CC,LINK}FLAGS which define the
  compiler/linker flags specifying the kind of position independence
  the kernel shall have. For x86 we had and still have -fno-pic, but the
  PPC kernel has -fPIE (position independent executable) now, as we
  need to relocate it.
* The boot loader relocates the kernel now. Mostly copied the relocation
  code from the kernel ELF loader. Almost completely rewrote the PPC
  specific relocation code, though. It's more correct and more complete now
  (some things are still missing though).
* Added boot platform awareness to the kernel. Moved the generic
  Open Firmware code (openfirmware.c/h) from the boot loader to the kernel.
* The kernel PPC serial debug output is sent to the console for the time
  being.
* The PPC boot loader counts the CPUs now and allocates the kernel stacks
  (made OF device iteration a bit more flexible on the way -- the search
  can be restricted to subtree). Furthermore we really enter the kernel...
  (Yay! :-) ... and crash in the first dprintf() (in the atomic_set()
  called by acquire_spinlock()). kprintf() works, though.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15756 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-30 21:20:07 +00:00
Axel Dörfler
140dd51293 cache_abort_transaction() could let cached_block::parent_data have the same value
as cached_block::data - which led to a crash as block_cache::FreeBlock() tried to
free both later.
Since neither cached_block::parent_data nor cached_block::original are supposed
to be != NULL in block_cache::FreeBlock(), they are no longer freed, but the system
panics if one of them is not NULL.
This should fix bug #77.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15749 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-30 18:47:16 +00:00
Ingo Weinhold
7022600734 Don't know what kernel_args::bootdir_addr was originally intended for,
but it's not initialized anymore.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15745 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-30 17:56:08 +00:00
Axel Dörfler
529bf1c6d7 block_range::Delete() did not remove the block_range from the free list,
and thus, it could be used again which led to a crash.
Changed the free ranges list from a singly linked list to a doubly linked
list so that not all free ranges have to be searched for the one to be
freed anymore.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15696 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-28 16:40:05 +00:00
Axel Dörfler
3dcaf063c2 Cleaned up locking and fixed a related bug: put_cached_block() could have been called without holding the cache lock.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15695 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-28 16:24:09 +00:00
Axel Dörfler
c004406e92 * Fixed a stupid bug in vm_page_write_modified() I introduced recently: if pages having
the modified bit set were written back (that's the case when they weren't put into
  the modified pages queue yet), they were enqueued into the active queue twice, messing
  up the page lists with various effects - this little thing took me busy for the last
  few days :-/
* Improved the "page" debugger command: it now prints out much more info, and also lets
  you lookup pages via physical address.
* The dump commands are now using kprintf() instead of dprintf().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15692 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-28 13:29:25 +00:00
Ingo Weinhold
21796ee568 Added newly required functions arch_cpu_init_post_modules() and
arch_cpu_user_TLB_invalidate(). Empty at the moment; will have a look at
that later. The PPC kernel builds again, now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15685 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-27 21:19:44 +00:00
Ingo Weinhold
31cfffdff4 Added missing include.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15684 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-27 21:17:25 +00:00
Axel Dörfler
447308b363 Enabled on-screen KDL by default.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15681 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-27 20:49:28 +00:00
Axel Dörfler
6aeb59944d Fixed printing stack trace of crashed apps.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15680 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-27 11:28:03 +00:00
Axel Dörfler
032a2d2805 Added "bt" to print a stack crawl to get less confused by gdb :-)
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15660 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-22 23:54:51 +00:00
Axel Dörfler
0c19920751 Improved debug output, added missing owner info to _dump_area().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15653 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-22 01:08:51 +00:00
Axel Dörfler
7a3e1b6979 Slightly improved debug output.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15652 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-22 00:47:37 +00:00
Axel Dörfler
f31dc4dd08 Improved tabulator for the on screen KDL.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15651 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-22 00:43:21 +00:00
Axel Dörfler
ebe5949e61 The debugger command "areas" can now restrict the list by team ID.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15650 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-22 00:40:34 +00:00
Axel Dörfler
c1b5724035 My last commit broken vm_clone_area(): it didn't grab a reference to its
cache, and therefore, let the kernel crash easily.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15649 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-22 00:04:28 +00:00
Axel Dörfler
db39fa281e Moved the headers of the different store implementations into the VM source
directory; they are not used outside the VM.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15648 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-21 20:08:49 +00:00
Axel Dörfler
16cfe613cd Fixed vfs_lookup_vnode() - it's not called with the mutex already locked anymore.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15647 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-21 20:07:33 +00:00
Axel Dörfler
14e132e2bc Reactivated check for failed semaphore creation - after kernel startup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15644 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-21 17:58:49 +00:00
Axel Dörfler
a8a13a0ae5 During early boot, there are no semaphores - but vm_cache_ref are already created...
Must be further investigated (if the locks are created later or not...)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15643 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-21 17:47:50 +00:00
Axel Dörfler
1e12fe8e5d A vm_cache can no longer be created with a NULL vm_store (nobody did it before,
but it would have worked - and crashed soon after).
Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15642 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-21 17:05:50 +00:00
Axel Dörfler
ea2cd27e57 * Fixed the strange vm_cache_ref reference count mechanism: now, a fresh
vm_cache_ref starts with a reference count of 1. When acquiring a vm_cache,
  you no longer need to worry if that should go through the vm_store, or not;
  as it now always does.
* map_backing_store() no longer needs to play with the vm_cache_ref
  references.
* that simplified some code.
* vfs_get_vnode_cache() now grabs a reference to the cache, if successful.
* better balanced vnode ownership on vnode_store creation (vnode_store
  released the vnode before if its creation failed).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15641 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-21 17:00:03 +00:00
Axel Dörfler
d5abe15e84 The name elf_load_user_image() chooses for the area is now actually limited
to B_OS_NAME_LENGTH bytes, instead of 64. Also, it will now only consider
the leaf name for the area.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15640 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-21 16:47:46 +00:00
Axel Dörfler
79f73dbc56 * vm_page::offset is now called cache_offset and is now an uint32 instead of off_t;
this saves 4 bytes per page. To compensate the loss of bytes, the offset is now
  stored in page size units, that's enough to address 2^44 or 16 TB (which is now
  the maximal supported file size!).
* Renamed vm_page::ppn to physical_page_number.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15637 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-21 12:38:31 +00:00
Axel Dörfler
d608540b67 Separated vm_address_space.h from vm.h.
Some more cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15614 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-20 15:54:45 +00:00
Axel Dörfler
4318316c65 This should fix PPC build after recent changes.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15610 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-20 13:31:38 +00:00
Axel Dörfler
96e01a27bf * Merged vm_virtual_map with vm_address_space - there was no reason to have
them apart (this even saves a pointer from vm_virtual_map to its address space)
* aspace -> address_space
* vm_create_address_space() did not check if creating the semaphore succeeded
* Removed team::kaspace - was not really needed (introduced a new vm_kernel_address_space()
  function that doesn't grab a reference to the address space)
* Removed vm_address_space::name - it was just a copy of the team name, anyway,
  and there is always only one address space per team
* Removed aspace_id - the address space is now using the team_id
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15609 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-20 13:29:11 +00:00
Axel Dörfler
9d845483cf Got rid of two ToDo-items: instead of clearing the PAGE_MODIFIED flag after having
written the page, we now do it before, so that it cannot lose any changed data
anymore; it doesn't matter if the page is written to while writing it back, the
worst thing that can happen is that we write the same page twice. Also, we don't
rely on the PAGE_MODIFIED bit anymore, we now check all mappings of that page
to find all modified pages, no matter how far the (currently disabled) page
daemon had come.
Also, destroying an area will now result in writing back changed pages - this
is only really important for memory mapped files, though, and should probably
be avoided for other vm_store types.
Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15597 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-19 23:01:11 +00:00
Axel Dörfler
89f5f72a15 * Added debug output to vm_low_memory.cpp.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15568 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-16 17:35:03 +00:00
Axel Dörfler
d0d37bdfd1 * vfs_init() is now called later in the startup sequence - since no core kernel
service depends on it, it doesn't make any sense to call it that early in the
  game.
* The VFS now has a low memory handler for vnodes as well. If there is enough
  memory left, it won't free any vnodes anymore.
* Potential crashing bug fix: some functions did not check if the FD passed
  in belonged to the right type; they just assumed it had a valid vnode, but
  it could have had a mount structure associated as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15566 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-16 16:11:36 +00:00
Axel Dörfler
4c0f46e2a3 The block_cache::LowMemoryHandler() must check if it could acquire the cache's lock;
it might have been deleted in the mean time.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15565 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-16 15:50:13 +00:00
Axel Dörfler
182f88dda1 * block_cache_delete() now deletes the cache with with its lock held.
* the link were not initialized in cached_block, as its constructor were never called
  (was using malloc/free instead of new/delete).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15564 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-16 15:45:00 +00:00
Axel Dörfler
005108a262 Forget to remove debug output.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15563 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-16 14:33:10 +00:00
Axel Dörfler
37bd67edb8 Now also flushes dirty blocks correctly (cannot happen if transactions are used,
ie. never happens with BFS).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15562 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-16 13:53:34 +00:00
Axel Dörfler
41e866f3ae The block cache now registers and uses a low memory handler that will flush
unused blocks when needed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15561 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-16 13:49:23 +00:00
Axel Dörfler
7d7f4675bb * Added some cpuid eax == 1 feature definitions to arch_cpu.h
* Renamed IA32_MTR_WRITE_COMBINED to IA32_MTR_WRITE_COMBINING.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15559 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-16 12:25:49 +00:00
Axel Dörfler
ebdb9dfebf Blocks are now put into an unused list when they aren't used.
When memory gets low, the blocks on that list are also freed - but right now,
that only happens when a block is put back (not directly on demand, ie. via
a low memory handler).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15552 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-15 21:35:19 +00:00
Axel Dörfler
1534aa236c Added new function vm_low_memory_state() that returns the current low
memory status.
Added new B_NO_LOW_MEMORY constant for the usual case.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15551 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-15 21:30:28 +00:00
Axel Dörfler
b3e26f5b8f Documented the block cache allocator a bit.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15546 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-15 16:23:30 +00:00
Rudolf Cornelissen
09116ce3bc removed the switch statement for determining number of CPU's in a system. This should fix CPU 'hlt' instruction not being executed in SMP systems idle loop. Thanks Axel and Ingo for pointing me at this.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15544 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-15 12:25:11 +00:00
Axel Dörfler
e0e9a3e69f * We now support the global page feature of x86 processors that prevents
kernel TLBs from being flushed on context switch.
* new arch_cpu_user_TLB_invalidate() that now does what arch_cpu_global_TLB_invalidate()
  did before.
* arch_cpu_global_TLB_invalidate() will now flush all TLBs, even those from the
  kernel.
* some cleanups.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15535 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-14 17:07:37 +00:00
Axel Dörfler
51a3c450be The short story: we now have MTRR support on Intel and AMD CPUs (the latter
has not yet been tested, though - I'll do this after this commit):
* Removed the arch_memory_type stuff from vm_area; since there are only 8 memory
  ranges on x86, it's simply overkill. The MTRR code now remembers the area ID
  and finds the MTRR that way (it could also iterate over the existing MTRRs).
* Introduced some post_modules() init functions.
* If the other x86 CPUs out there don't differ a lot, MTRR functionality might
  be put back into the kernel.
* x86_write_msr() was broken, it wrote the 64 bit number with the 32 bit words
  switched - it took me some time (and lots of #GPs) to figure that one out.
* Removed the macro read_ebp() and introduced a function x86_read_ebp()
  (it's not really a time critical call).
* Followed the Intel docs on how to change MTRRs (symmetrically on all CPUs
  with caches turned off).
* Asking for memory types will automatically change the requested length to
  a power of two - note that BeOS seems to behave in the same, although that's
  not really very clean.
* fixed MTRRs are ignored for now - we should make sure at least, though,
  that they are identical on all CPUs (or turn them off, even though I'd
  prefer the BIOS stuff to be uncacheable, which we don't enforce yet, though).



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15528 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-13 16:34:29 +00:00
Axel Dörfler
2ed21b8525 Some work in progress of the MTRR support. Shouldn't do any harm yet :-)
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15525 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-13 00:06:52 +00:00
Axel Dörfler
b7e7814c79 Prints a warning if open_modules_list() or get_next_loaded_module_name() are
called before module_init(). Maybe it's even better to drop into the kernel
debugger.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15524 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-13 00:01:19 +00:00
Axel Dörfler
97ec781e94 Added (empty) memory type functions to the PPC port.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15521 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-12 17:13:15 +00:00
Axel Dörfler
7c0a93573b Preparation for MTRR support, code is completely untested, though.
The CPU specific MTRR code will be in modules.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15520 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-12 17:04:36 +00:00
Axel Dörfler
381d6b57f6 Make sure system can continue after panic.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15519 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-12 17:00:46 +00:00
Axel Dörfler
b53cc465d6 Moved declaration of gBootDevice into its own header.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15518 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-12 16:06:33 +00:00
Axel Dörfler
aa9d29ba97 Another SMP oversight: the TSS was not explicetly loaded for all CPUs.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15517 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-12 14:38:26 +00:00
Axel Dörfler
185a5a57cd Removed old PPC framebuffer console (this code is superseded by the on screen KDL). Updated files to match current arch API. This fixes the kernel build for PPC.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15411 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-08 11:03:24 +00:00
Axel Dörfler
82e9603fbf Disabled page daemon for now - it doesn't any good yet (but easily sucks up your CPU power).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15308 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-04 16:47:52 +00:00
Axel Dörfler
6aae81b3e1 Quick and dirty fix to allow our heap to allocate more than 64kB.
However, it will never free those allocations again.
This fixes the problems due to Rudolf's recent driver updates.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15248 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-30 19:28:46 +00:00
Ingo Weinhold
353d20c0c5 * libroot and the runtime loader are no longer built with kernel rules.
* New rule Ld, analogously to KernelLd.
* Added StaticLibrary parameter for supplying additional objects.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15191 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-27 13:31:50 +00:00
Ingo Weinhold
38f6264454 Reorganized building of kernel, boot loader, and libroot.
Each component is built in the respective subdirectory now
and no longer in src/system/Jamfile.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15184 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-27 00:27:19 +00:00
Axel Dörfler
2bea891d75 Debug output change: vm_page_fault() doesn't kill the team anymore, it just
sends a SIGSEGV signal (and lets the debugger handle the rest).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15145 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-25 12:43:14 +00:00
Axel Dörfler
ecf2e38db2 Reset last_acquirer in case the semaphore gets released.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15144 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-25 12:34:54 +00:00
Axel Dörfler
9240f51352 Fixed a major oversight in the interrupt handling: when a user space
application got interrupted, thread_at_kernel_exit() was called - but
that expected interrupts to be enabled for signal handling.
However, only exceptions 3 (breakpoint) and 99 (syscall) are trap
gates, and thus, only those actually had interrupt enabled at that
point.
If a KILL signal was pending when a hardware interrupt interrupted a
user space thread you were entering KDL before ("acquire_sem() called
with interrupts turned off").
Thanks to mouse interrupts I finally got this often enough to find
this...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15143 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-25 12:26:56 +00:00
Axel Dörfler
2b028fcaa0 Removed one TODO from the list: in case pages_io() fails, read_chunk_into_cache()
will no longer panic, but free its allocated pages.
I ran into this because BFS managed to create a file without data stream but
with a length larger than 0...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15093 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-23 18:36:38 +00:00
Ingo Weinhold
aeef8a1098 Reverted to the previous version. I was too quick; the boot loader
doesn't link against libsupc++ and still needs the symbol.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14972 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-16 20:51:17 +00:00
Ingo Weinhold
9b2e76121b No need to define __cxa_pure_virtual. We're linking against libsupc++ anyway.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14967 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-16 17:35:41 +00:00
Ingo Weinhold
6d865282d4 Link the kernel against libsupc++.a -- we're using RTTI after all. Added
missing symbols to kernel_cpp.cpp.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14965 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-16 17:25:54 +00:00
Ingo Weinhold
758b1d0e05 Fixes that make Haiku build with gcc 4. Mainly out of the following
categories:
* Missing includes (like <stdlib.h> and <string.h>).
* Linking against $(TARGET_LIBSTDC++) instead of libstdc++.r4.so.
* Local variables shadowing parameters.
* Default parameters in function definitions (as opposed to function
  declarations).
* All C++ stuff (nothrow, map, set, vector, min, max,...) must be imported
  explicitly from the std:: namespace now.
* "new (sometype)[...]" must read "new sometype[...]", even if sometype is
  something like "const char *".
* __FUNCTION__ is no longer a string literal (but a string expression), i.e.
  'printf(__FUNCTION__ ": ...\n")' is invalid code.
* A type cast results in a non-lvalue. E.g. "(char *)buffer += bytes"
  is an invalid expression.
* "friend class SomeClass" only works when SomeClass is known before.
  Otherwise the an inner class with that name is considered as friend.
  gcc 4 is much pickier about scopes.
* gcc 4 is generally stricter with respect to type conversions in C.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14878 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-12 23:27:14 +00:00
Axel Dörfler
04cd47db59 common_access() now follows the same logic as traversing paths: if the file system
doesn't export the fs_access() function, it assumes access is granted.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14816 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-10 11:17:03 +00:00
Marcus Overhagen
9ae89b4535 bugfix
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14710 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-04 20:01:47 +00:00
Axel Dörfler
c5eb28a359 Now uses the new image_debug_lookup_user_symbol_address() call.
The stack frame that got interrupted were missing from the stack output
(and thus the call that got us into the kernel).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14706 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-04 17:28:08 +00:00