Commit Graph

9 Commits

Author SHA1 Message Date
Martin Stein bfe1fac37c hw_x86_64: style fixes
Ref #1448
2015-03-27 11:53:34 +01:00
Adrian-Ken Rueegsegger 96a3eabe16 hw_x86_64: Log additional information on unknown exception
Provide more information in the log message when an unknown exception
occurs.
2015-03-27 11:53:32 +01:00
Reto Buerki 28b5e67a8c Update or add hw_x86_64 copyright headers 2015-03-27 11:53:32 +01:00
Adrian-Ken Rueegsegger 7ce8464b3a hw_x86_64: Enable FPU support
* Enable the use of the FXSAVE and FXRSTOR instructions, see Intel SDM
  Vol. 3C, section 2.5.
* The state of the x87 floating point unit (FPU) is loaded and saved on
  demand.
* Make the cr0 control register accessible in the Cpu class. This is in
  preparation of the upcoming FPU management.
* Access to the FPU is disabled by setting the Task Switch flag in the cr0
  register.
* Access to the FPU is enabled by clearing the Task Switch flag in the cr0
  register.
* Implement FPU initialization
* Add is_fpu_enabled helper function
* Add pointer to CPU lazy state to CPU class
* Init FPU when finishing kernel initialization
* Add function to retry FPU instruction:
    Similar to the ARM mechanism to retry undefined instructions, implement a
    function for retrying an FPU instruction. If a floating-point instruction
    causes an #NM exception due to the FPU being disabled, it can be retried
    after the correct FPU state is restored, saving the current state and
    enabling the FPU in the process.
* Disable FPU when switching to different user context:
    This enables lazy save/restore of the FPU since trying to execute a
    floating point instruction when the FPU is disabled will cause a #NM
    exception.
* Declare constant for #NM exception
* Retry FPU instruction on #NM exception
* Assure alignment of FXSAVE area:
    The FXSAVE area is 512-byte memory region that must be 16-byte aligned. As
    it turns out the alignment attribute is not honored in all cases so add a
    workaround to assure the alignment constraint is met by manually rounding
    the start of the FXSAVE area to the next 16-byte boundary if necessary.
2015-03-27 11:53:31 +01:00
Reto Buerki c9c84dd751 base: Move Cpu_exception enum to x86_64 cpu_state.h 2015-03-27 11:53:31 +01:00
Reto Buerki 2ecdf4f729 hw_x86_64: Forward interrupts to _interrupt function
Extend the Thread::exception function to forward external interrupts to
the _interrupt function for processing.
2015-03-27 11:53:29 +01:00
Reto Buerki 0992c233bd hw_x86_64: Forward page faults to the _mmu_exception function 2015-03-27 11:53:28 +01:00
Reto Buerki 83a1b826a3 hw_x86_64: Add supervisor call handling to Thread::exception
Forward supervisor calls to the Thread::_call function for dispatching.
2015-03-27 11:53:28 +01:00
Norman Feske a974726e26 hw: skeleton for building on x86_64
This patch contains the initial code needed to build and bootstrap the
base-hw kernel on x86 64-bit platforms. It gets stuck earlier
because the binary contains 64-bit instructions, but it is started in
32-bit mode. The initial setup of page tables and switch to long mode is
still missing from the crt0 code.
2015-03-27 11:53:16 +01:00