Commit Graph

159 Commits

Author SHA1 Message Date
Marcus Overhagen a090257d09 Add volatile keyword to apic memory access, cleanup, add timeout to arch_smp_send_ici.
But this still doesn't help with bug #1018...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20231 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-25 23:32:21 +00:00
Jérôme Duval d4d9831990 merge both commpage.h into the private header
Travis, I hope this fits your needs :)


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


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


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20160 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-19 00:11:24 +00:00
Travis Geiselbrecht dfb5375d18 clean up TSS initialization.
Now two complete tss structures exist within the per-cpu structure. Instead
of having to create a seperate area per each one, initialize them in place.
Also, the old mechanism to getting all of the cpus to get initialized was 
subtly broken, but still managed to work. Now, just force all the cpus to
initialize at boot, which makes the actual swapping of esp0 somewhat simpler.


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


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20072 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-05 01:46:28 +00:00
Axel Dörfler 9ecaa867f7 Applied patch by Vasilis Kaoutsis: now checks for the MSR feature as well; obviously
some Pentium 200 MMX pretend to support MTRRs.
This should fix bug #553.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19899 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-22 14:45:50 +00:00
Axel Dörfler fa4858af26 Didn't notice that x86_enter_userspace() also copied the thread entry's arguments to
the userland stack in an unsafe way - moved that stuff to arch_thread_enter_userspace(), too.


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


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


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


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17806 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-06-12 22:24:53 +00:00
Michael Lotz 2a03240eb1 Reverted my last change as it turned out that the lazy FPU state handling was not SMP safe afterall and the performance gain is questionable. Maybe it'll be implemented correctly in the future. Sorry for any inconvenience this may have cost.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17272 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-29 22:10:04 +00:00
Michael Lotz 7eee76e65a Implemented lazy FPU state save/restore. In the end mostly ported from NewOS. SMP safe.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17251 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-04-27 22:02:48 +00:00
Axel Dörfler f94b06f992 Implemented SSE2/3 support (tested with VLC).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16569 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-02 17:12:56 +00:00
Ingo Weinhold f4b0f67cf6 Added [arch_]int_post_device_manager() which is invoked after
the device manager is initialized. For x86 it does nothing, but
for PPC it searches for a supported interrupt controller and
remembers it for later use.
arch_int_{enable,disable}_io_interrupt() are implemented as
well as handling of external exceptions (aka as I/O interrupts).
We'll see later how well that works.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16271 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-02-07 02:50:32 +00:00
Axel Dörfler 5da68569d0 The APM now successfully shuts down my IBM ThinkPad T40. It's still disabled
for more testing on other machines.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16136 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-29 15:51:33 +00:00
Axel Dörfler afd6dfc8b4 Implemented first basic APM driver. Only tested with QEMU so far, that's why
it's currently disabled.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16120 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-28 18:11:20 +00:00
Ingo Weinhold 6cdd45a94b Added enum to PPCPlatform to identify the platform.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16099 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-26 14:59:16 +00:00
Ingo Weinhold 7afc16f059 * Fixed a bug regarding storing/restoring FPSCR in the interrupt
code. The stack pointer was not adjusted, hence we were
  overwriting the previous register value. But it looks like I
  missed to check in the arch_cpu.h with the iframe structure
  including the floating point registers anyway.
* Backported the ELF PPC relocation code from the boot loader to
  the kernel.
* Fixed the PPC version of arch_thread_switch_kstack_and_call().
  Apparently the signature had changed, but the assembly
  implementation was not adjusted accordingly.
* sc prints more registers now (LR, CR, CTR, XER,...).
* Fixed several occurences of not-working fault handlers.
  Apparently the compiler realized, that the "error" label was
  never jumped to (by the code it knew), and optimized the
  respective code away. Now we use a trick to make it think the
  error label might actually be jumped to. I wonder whether the
  x86 version has the same problem when being compiled with GCC4.
* Adopted the x86 page fault handling interrupt code.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15933 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-13 00:49:13 +00:00
Ingo Weinhold fc1e671b53 Made C++ safe.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15911 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-11 14:36:43 +00:00
Axel Dörfler ba61df6d0b Beginnings of APM support: we now connect to the APM BIOS in 32 bit protected mode.
We don't do anything with it yet, though, so the BIOS will probably ignore us since
we are supposed to poll for events.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15900 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-10 22:54:36 +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 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 c9eb843c35 Added comment about the use of some special purpose registers.
Haven't found a better place yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15880 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-09 03:11:31 +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 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 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
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 a1bcf2c880 * The OF memory management callback is now set in arch_mmu_init().
According to the spec we need to set it before taking over the MMU,
  but we can't call it before arch_mmu_init(), since we need the OF
  to allocate the page table. So we do it after we have allocated
  the new page table.
* Added PPC specific kernel_args: The virtual address ranges we want
  to keep in the kernel. We fill that in with the translations we
  find when initializing the MMU stuff. We remove the memory the
  boot loader occupies from those. Besides the stack for the boot
  loader only the OF stuff remains.
* arch_mmu_allocate() now starts to search at KERNEL_BASE for a free
  virtual address when no particular address is requested. This saves
  us further trouble in the kernel, since those allocations would
  need to be remapped otherwise.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15780 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-02 01:56:37 +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 7c8af51f81 Added ptesync().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15768 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-01 14:44:29 +00:00
Ingo Weinhold 8d99b63e92 Added missing PPC relocation type.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15752 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-30 19:49:42 +00:00
Ingo Weinhold d0714598fd Fixed PPC build.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15679 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-27 01:51:43 +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 35cf51550c Replaced arch/thread_struct.h with arch/thread_types.h, and renamed
arch/*/thread_struct.h to arch_thread_types.h, so that it can directly
be included without having to specify the architecure.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15616 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-20 16:07:27 +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 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 484c80abd0 * Added missing prototypes for get_eflags() and set_eflags() to arch_system_info.h
* The boot loader now checks the CPU for the cpuid and rdtsc features, which we
  currently both rely on.
* Removed old and no longer used stage2_priv.h header


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15534 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-14 10:43:28 +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 d49423aea3 Added a wbinvd() macro.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15526 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-13 01:49:44 +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 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 7b7c38a2a7 The "where" or "sc" command now switches the page directory to the specified thread
to be able to follow the stack trace into userland.
No symbols there, yet, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14697 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-04 15:58:04 +00:00
Ingo Weinhold 338b8dc301 Merged changes from branch build_system_redesign at revision 14573.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14574 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-10-29 16:27:43 +00:00
Axel Dörfler 90ce9e8305 Added calls to read and write the MSR, the machine state register.
Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14537 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-10-26 23:39:38 +00:00