From ecaad9ecce8557722e3471cab6088167acfdd085 Mon Sep 17 00:00:00 2001 From: Reto Buerki Date: Thu, 26 Feb 2015 13:51:56 +0100 Subject: [PATCH] hw_x86_64: Add private _virt_idt_address member to Idt class This function calculates the address of the IDT for a given virtual mode transition base address. --- repos/base-hw/src/core/include/spec/x86_64/idt.h | 6 ++++++ repos/base-hw/src/core/spec/x86_64/idt.cc | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/repos/base-hw/src/core/include/spec/x86_64/idt.h b/repos/base-hw/src/core/include/spec/x86_64/idt.h index 7c51ac4d3..67666a9d8 100644 --- a/repos/base-hw/src/core/include/spec/x86_64/idt.h +++ b/repos/base-hw/src/core/include/spec/x86_64/idt.h @@ -21,6 +21,12 @@ class Genode::Idt SYSCALL_VEC = 0x80, }; + /** + * Return virtual address of the IDT for given virtual mode transition + * base. + */ + static addr_t _virt_idt_addr(addr_t const virt_base); + /** * 64-Bit Mode IDT gate, see Intel SDM Vol. 3A, section 6.14.1. */ diff --git a/repos/base-hw/src/core/spec/x86_64/idt.cc b/repos/base-hw/src/core/spec/x86_64/idt.cc index 4f3cf52f8..a14b1d82f 100644 --- a/repos/base-hw/src/core/spec/x86_64/idt.cc +++ b/repos/base-hw/src/core/spec/x86_64/idt.cc @@ -1,5 +1,8 @@ #include "idt.h" +extern int _mt_begin; +extern int _mt_idt; + using namespace Genode; class Descriptor @@ -13,6 +16,13 @@ class Descriptor } __attribute__((packed)); +addr_t Idt::_virt_idt_addr(addr_t const virt_base) +{ + addr_t const phys = (addr_t)&_mt_idt; + addr_t const phys_base = (addr_t)&_mt_begin; + return virt_base + (phys - phys_base); +} + void Idt::setup() { /* TODO: Calculate from _mt_isrs label */