/* * Copyright 2010 Stefan Lankes, Chair for Operating Systems, * RWTH Aachen University * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * This file is part of MetalSVM. */ /** * @author Stefan Lankes * @file arch/x86/include/asm/idt.h * @brief Definition of IDT flags and functions to set interrupts * * This file contains define-constants for interrupt flags * and installer functions for interrupt gates.\n * See idt.c for structure definitions. */ #ifndef __ARCH_IDT_H__ #define __ARCH_IDT_H__ #include /// This bit shall be set to 0 if the IDT slot is empty #define IDT_FLAG_PRESENT 0x80 /// Interrupt can be called from within RING0 #define IDT_FLAG_RING0 0x00 /// Interrupt can be called from within RING1 and lower #define IDT_FLAG_RING1 0x20 /// Interrupt can be called from within RING2 and lower #define IDT_FLAG_RING2 0x40 /// Interrupt can be called from within RING3 and lower #define IDT_FLAG_RING3 0x60 /// Size of gate is 16 bit #define IDT_FLAG_16BIT 0x00 /// Size of gate is 32 bit #define IDT_FLAG_32BIT 0x08 /// The entry describes an interrupt gate #define IDT_FLAG_INTTRAP 0x06 /// The entry describes a trap gate #define IDT_FLAG_TRAPGATE 0x07 /// The entry describes a task gate #define IDT_FLAG_TASKGATE 0x05 /* * This is not IDT-flag related. It's the segment selectors for kernel code and data. */ #define KERNEL_CODE_SELECTOR 0x08 #define KERNEL_DATA_SELECTOR 0x10 #ifdef __cplusplus extern "C" { #endif /** @brief Installs IDT * * The installation involves the following steps: * - Set up the IDT pointer * - Set up int 0x80 for syscalls * - process idt_load() */ void idt_install(void); /** @brief Set an entry in the IDT * * @param num index in the IDT * @param base base-address of the handler function being installed * @param sel Segment the IDT will use * @param flags Flags this entry will have */ void idt_set_gate(unsigned char num, unsigned long base, unsigned short sel, unsigned char flags); #ifdef __cplusplus } #endif #endif