feat: gestion chargement d'une nouvelle GDT - non fonctionnel

This commit is contained in:
Nicolas Hordé 2018-09-01 22:58:05 +02:00
parent debba65eba
commit b1abb2f5a2
3 changed files with 50 additions and 5 deletions

View File

@ -2,13 +2,47 @@
#include "asm.h"
#include "types.h"
#define SIZEGDT 0x4 /* nombre de descripteurs */
#define BASEGDT 0x00000800 /* addr de la GDT */
/* registre gdt */
static struct gdtr gdtreg;
/* table de GDT */
static gdtdes gdt[SIZEGDT];
/*******************************************************************************/
/* Initialise la GDT */
void initgdt()
{
makegdtdes(0x0, 0x00000, 0x00, 0x00, &gdt[0]);
makegdtdes(0x0, 0xFFFFF, 0x9B, 0x0D, &gdt[1]); /* code */
makegdtdes(0x0, 0xFFFFF, 0x93, 0x0D, &gdt[2]); /* data */
makegdtdes(0x0, 0x00000, 0x97, 0x0D, &gdt[3]); /* pile */
/* initialise le registre gdt */
gdtreg.limite = SIZEGDT * 8;
gdtreg.base = BASEGDT;
/* recopie de la GDT a son adresse */
memcpy(&gdt, (u8 *) gdtreg.base, gdtreg.limite, 1);
/* chargement du registre GDT */
lgdt(&gdtreg);
/* initialisation des segments */
asm(" movw $0x10, %ax \n \
movw %ax, %ds \n \
movw %ax, %es \n \
movw %ax, %fs \n \
movw %ax, %gs \n \
movl 0x0C(%esp), %eax \n \
movw $0x18, %ax \n \
movw %ax, %ss \n \
movl $0x20000, %esp \n \
pushl %eax \n \
ljmp $0x08, $raz \n \
raz: \n \
ret\n");
}
/*******************************************************************************/

View File

@ -4,6 +4,10 @@
#include "memory.h"
#include "video.h"
#define SIZEIDT 256 /* nombre de descripteurs */
#define BASEIDT 0x00000000 /* addr de la IDT */
/* registre idt */
static struct idtr idtreg;
@ -535,12 +539,12 @@ void initidt(void)
putidt((u32) irq13, 0x20, INTGATE, 101);
putidt((u32) irq14, 0x20, INTGATE, 102);
putidt((u32) irq15, 0x20, INTGATE, 103);
for (i = 104; i <= 255; i++) {
for (i = 104; i < SIZEIDT; i++) {
putidt((u32) interruption, 0x20, TRAPGATE, i);
}
/* initialise le registre idt */
idtreg.limite = 256 * 8;
idtreg.base = 0x0000000;
idtreg.limite = SIZEIDT * 8;
idtreg.base = BASEIDT;
/* recopie de la IDT a son adresse */
memcpy(&idt, (u8 *) idtreg.base, idtreg.limite, 1);
/* chargement du registre IDTR */

View File

@ -46,7 +46,14 @@ int main(void)
print("\033[2J\000");
printf(ansilogo);
print("\033[37m\033[0m -Initilisation des interruptions\000");
print("\033[37m\033[0m -Chargement noyaux\000");
ok();
print("\033[37m\033[0m -Initilisation de la memoire (GDT)\000");
initgdt();
ok();
print("\033[37m\033[0m -Initilisation des interruptions (IDT/PIC)\000");
initidt();
initpic();
sti();