100 lines
2.3 KiB
C
100 lines
2.3 KiB
C
/* interrupt.h - This file is a part of NutsOS
|
|
*
|
|
* NutsOS
|
|
* Copyright (C) 2013 Free Software Foundation, Inc.
|
|
*
|
|
* NutsOS is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* NutsOS is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with NutsOS; If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* Valentin Verdier <valentin.verdier03@gmail.com>
|
|
*/
|
|
|
|
#pragma once
|
|
#ifndef INTERRUPT_H
|
|
#define INTERRUPT_H
|
|
|
|
#include "types.h"
|
|
|
|
/* === Configuration du PIC 8259A === */
|
|
|
|
#define PIC_MASTER_CMD_REG 0x20
|
|
#define PIC_MASTER_DATA_REG 0x21
|
|
#define PIC_MASTER_IDT_OFFSET 0x20
|
|
|
|
#define PIC_SLAVE_CMD_REG 0xA0
|
|
#define PIC_SLAVE_DATA_REG 0xA1
|
|
#define PIC_SLAVE_IDT_OFFSET 0x28
|
|
|
|
#define PIC_EOI 0x20
|
|
|
|
void PIC_init();
|
|
void PIC_maskIRQ(T_byte);
|
|
void PIC_sendEOI();
|
|
|
|
/* ======================================================================== */
|
|
|
|
|
|
/* ===== Manipulation de l'IDT ===== */
|
|
|
|
#define IDT_BASE 0x200800
|
|
#define INT_DESC_SIZE 8
|
|
#define IDT_SIZE 256
|
|
|
|
#define DIVIDE_BY_0_INT 0
|
|
#define NMI_INT 2
|
|
#define BREAKPOINT_INT 3
|
|
#define OVERFLOW_INT 4
|
|
#define INVALID_TSS_INT 10
|
|
|
|
#define SEG_FAULT_INT 11
|
|
#define STACK_SEG_FAULT_INT 12
|
|
#define GP_FAULT_INT 13
|
|
#define PAGE_FAULT_INT 14
|
|
|
|
#define TIMER_INT 32
|
|
#define KB_INT 33
|
|
#define SYS_CALL_INT 64
|
|
|
|
typedef struct {
|
|
T_word offset0_15;
|
|
T_word segment;
|
|
T_word type;
|
|
T_word offset16_31;
|
|
}__attribute__((packed)) T_IDT_desc;
|
|
|
|
typedef struct {
|
|
T_word limite;
|
|
T_dword base;
|
|
}__attribute__((packed)) T_IDT_reg;
|
|
|
|
|
|
void IDT_init();
|
|
void IDT_createDesc(T_dword, T_word, T_word, unsigned int);
|
|
|
|
/* ======================================================================== */
|
|
|
|
|
|
/* Routine d'interruption en assembleur (redirection vers routines en C) */
|
|
|
|
void _defaultInt();
|
|
void _SEG_fault();
|
|
void _GP_fault();
|
|
void _page_fault();
|
|
void _clockInterrupt();
|
|
void _syscall();
|
|
|
|
/* ======================================================================== */
|
|
|
|
|
|
#endif
|