x86: fix IDT entry definition

It was, in a nutshell, wrong. Fortunately, the incorrectly
specified fields weren't being used by anything.

Change-Id: I0fa63fa16a267502744a7a2c82865c7de8b5446e
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2016-01-27 14:12:11 -08:00 committed by Gerrit Code Review
commit 313ed31253
3 changed files with 32 additions and 20 deletions

View file

@ -96,8 +96,8 @@ uint8_t _stub_idx_from_vector(int vector)
* the dynamic stubs * the dynamic stubs
*/ */
idt_entry = (IDT_ENTRY *)(_idt_base_address + (vector << 3)); idt_entry = (IDT_ENTRY *)(_idt_base_address + (vector << 3));
stub_addr = (uint8_t *)((uint32_t)idt_entry->lowOffset + stub_addr = (uint8_t *)((uint32_t)idt_entry->offset_low +
((uint32_t)idt_entry->hiOffset << 16)); ((uint32_t)idt_entry->offset_high << 16));
/* /*
* Return the specific byte in the handler code which contains * Return the specific byte in the handler code which contains

View file

@ -46,22 +46,34 @@ extern "C" {
#define _EXC_ERROR_CODE_FAULTS 0x27d00 #define _EXC_ERROR_CODE_FAULTS 0x27d00
/* /**
* Interrupt Descriptor Table (IDT) entry structure * @brief Interrupt Descriptor Table (IDT) entry structure
* *
* (This is taken from Intel documentation, so don't try to interpret it * See section 6.11 in x86 CPU manual vol. 3A
* too deeply.)
*/ */
typedef struct idt_entry {
typedef struct idtEntry { union {
unsigned short lowOffset; uint16_t offset_low;
unsigned short segmentSelector; uint16_t reserved_task_gate_0;
unsigned short reserved:5; };
unsigned short intGateIndicator:8; uint16_t segment_selector;
unsigned short descPrivLevel:2; union {
unsigned short present:1; struct {
unsigned short hiOffset; uint8_t reserved:5;
} __packed IDT_ENTRY; uint8_t always_0_0:3;
};
uint8_t reserved_task_gate_1;
};
uint8_t type:3; /* task:101, irq:110, trap:111 */
uint8_t gate_size:1; /* size of gate, 1: 32-bit, 0:16-bit */
uint8_t always_0_1:1;
uint8_t dpl:2; /* Descriptor privilege level */
uint8_t present:1; /* present yes/no */
union {
uint16_t offset_high;
uint16_t reserved_task_gate_2;
};
} __packed IDT_ENTRY;
/** /**
* *

View file

@ -116,14 +116,14 @@ int nanoIdtStubTest(void)
pIdtEntry = (IDT_ENTRY *) (_idt_base_address + (TEST_SOFT_INT << 3)); pIdtEntry = (IDT_ENTRY *) (_idt_base_address + (TEST_SOFT_INT << 3));
offset = (uint16_t)((uint32_t)(&nanoIntStub) & 0xFFFF); offset = (uint16_t)((uint32_t)(&nanoIntStub) & 0xFFFF);
if (pIdtEntry->lowOffset != offset) { if (pIdtEntry->offset_low != offset) {
TC_ERROR("Failed to find low offset of nanoIntStub " TC_ERROR("Failed to find low offset of nanoIntStub "
"(0x%x) at vector %d\n", (uint32_t)offset, TEST_SOFT_INT); "(0x%x) at vector %d\n", (uint32_t)offset, TEST_SOFT_INT);
return TC_FAIL; return TC_FAIL;
} }
offset = (uint16_t)((uint32_t)(&nanoIntStub) >> 16); offset = (uint16_t)((uint32_t)(&nanoIntStub) >> 16);
if (pIdtEntry->hiOffset != offset) { if (pIdtEntry->offset_high != offset) {
TC_ERROR("Failed to find high offset of nanoIntStub " TC_ERROR("Failed to find high offset of nanoIntStub "
"(0x%x) at vector %d\n", (uint32_t)offset, TEST_SOFT_INT); "(0x%x) at vector %d\n", (uint32_t)offset, TEST_SOFT_INT);
return TC_FAIL; return TC_FAIL;
@ -133,14 +133,14 @@ int nanoIdtStubTest(void)
pIdtEntry = (IDT_ENTRY *) (_idt_base_address + (IV_DIVIDE_ERROR << 3)); pIdtEntry = (IDT_ENTRY *) (_idt_base_address + (IV_DIVIDE_ERROR << 3));
offset = (uint16_t)((uint32_t)(&exc_divide_error_handlerStub) & 0xFFFF); offset = (uint16_t)((uint32_t)(&exc_divide_error_handlerStub) & 0xFFFF);
if (pIdtEntry->lowOffset != offset) { if (pIdtEntry->offset_low != offset) {
TC_ERROR("Failed to find low offset of exc stub " TC_ERROR("Failed to find low offset of exc stub "
"(0x%x) at vector %d\n", (uint32_t)offset, IV_DIVIDE_ERROR); "(0x%x) at vector %d\n", (uint32_t)offset, IV_DIVIDE_ERROR);
return TC_FAIL; return TC_FAIL;
} }
offset = (uint16_t)((uint32_t)(&exc_divide_error_handlerStub) >> 16); offset = (uint16_t)((uint32_t)(&exc_divide_error_handlerStub) >> 16);
if (pIdtEntry->hiOffset != offset) { if (pIdtEntry->offset_high != offset) {
TC_ERROR("Failed to find high offset of exc stub " TC_ERROR("Failed to find high offset of exc stub "
"(0x%x) at vector %d\n", (uint32_t)offset, IV_DIVIDE_ERROR); "(0x%x) at vector %d\n", (uint32_t)offset, IV_DIVIDE_ERROR);
return TC_FAIL; return TC_FAIL;