os-k/include/ke/idt.h

102 lines
3.5 KiB
C
Raw Normal View History

2019-05-01 14:17:16 +02:00
//----------------------------------------------------------------------------//
// GNU GPL OS/K //
// //
// Desc: Interrupt related functions //
// //
// //
// Copyright © 2018-2019 The OS/K Team //
// //
// This file is part of OS/K. //
// //
// OS/K 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 //
// any later version. //
// //
// OS/K 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 OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
2019-05-13 23:22:27 +02:00
#ifndef _KERNEL_H
#include <kernel.h>
2019-04-24 11:40:28 +02:00
#endif
#ifndef _KALKERN_IDT_H
#define _KALKERN_IDT_H
2019-05-01 14:17:16 +02:00
//----------------------------------------------------------------------------//
2019-04-24 11:40:28 +02:00
2019-05-01 14:17:16 +02:00
struct IdtDescriptor_t
{
2019-04-24 11:40:28 +02:00
ushort limit;
ulong base;
2019-05-01 14:17:16 +02:00
} __attribute__((packed));
2019-04-24 11:40:28 +02:00
struct IdtEntry_t
{
ushort baseLow;
ushort selector;
uchar reservedIst;
uchar flags;
ushort baseMid;
uint baseHigh;
uint reserved;
} __attribute__((packed));
struct IdtPtr_t
{
ushort limit;
void *base;
} __attribute__((packed));
2019-05-06 22:04:22 +02:00
struct ISRList_t
2019-04-24 11:40:28 +02:00
{
uchar n; //number of entries in the list
struct entry {
2019-04-27 00:04:27 +02:00
void (*isr)(ISRFrame_t *regs);
2019-05-06 22:04:22 +02:00
uchar isrNo;
2019-04-24 11:40:28 +02:00
uchar flags;
2019-05-06 22:04:22 +02:00
} entry[255];
2019-04-24 11:40:28 +02:00
};
2019-04-26 20:11:08 +02:00
typedef struct
{
} __attribute__((__packed__)) cpu_state_t;
2019-05-01 14:17:16 +02:00
extern char *IsrExceptions[32];
2019-04-24 11:40:28 +02:00
2019-05-01 14:17:16 +02:00
//----------------------------------------------------------------------------//
2019-04-24 11:40:28 +02:00
2019-05-01 14:17:16 +02:00
void IdtInit(void);
2019-04-24 11:40:28 +02:00
void IdtSetup(void);
2019-05-01 14:17:16 +02:00
void IoSendEOItoPIC(uchar isr);
2019-05-06 22:04:22 +02:00
void IdtEarlyExceptionHandler(ISRFrame_t *regs);
2019-05-01 14:17:16 +02:00
void IdtSetGate(uchar rank, ulong base, ushort selector, uchar flags);
2019-05-06 22:04:22 +02:00
error_t IdtRegisterIsr(void (*isr)(ISRFrame_t *regs), uchar isrNo);
2019-05-01 14:17:16 +02:00
//----------------------------------------------------------------------------//
#define _isr0(a,b,c,d,e) \
void isr##a(); void isr##b(); void isr##c(); void isr##d(); void isr##e()
#define _isr1(a,b,c,d,e,f,g,h,i,j) _isr0(a,b,c,d,e); _isr0(f,g,h,i,j)
_isr1(0,1,2,3,4,5,6,7,8,9); _isr1(10,11,12,13,14,15,16,17,18,19);
_isr1(20,21,22,23,24,25,26,27,28,29); _isr1(30,31,32,33,34,35,36,37,38,39);
_isr1(40,41,42,43,44,45,46,47,48,49); _isr1(50,51,52,53,54,55,56,57,58,59);
#undef _isr1
#undef _isr0
//----------------------------------------------------------------------------//
2019-04-24 11:40:28 +02:00
#endif