feat: ajout d'une interruption 20 qui permet de faire un DUMP du cpu sur l'écran

This commit is contained in:
Nicolas Hordé 2018-12-20 17:16:51 +01:00
parent eff52c8853
commit 945bca37b5
8 changed files with 41 additions and 6 deletions

View File

@ -7,6 +7,9 @@
# define _ASM
/******************************************************************************/
# define int20 asm("int $0x14")
# define halt() asm("hlt"::)
# define sti() asm("sti"::)

View File

@ -16,6 +16,7 @@ jmp exception_suite
.endm
.macro semidumpcpu
cli
pushl %ds
pushl %es
pushl %fs
@ -88,6 +89,16 @@ pushl $0x00
semidumpcpu
call sysenter_handler
.global wrapper_interruption20
wrapper_interruption20:
pushl %ss
pushl %esp
pushf
pushl %cs
pushl $0x14
semidumpcpu
call interruption_handler
.global wrapper_interruption
wrapper_interruption:
pushl %ss

View File

@ -247,8 +247,7 @@ unsigned convert(u32 keypressed)
else if (key == SCAN_F9)
{
regs dump;
show_cpu(&dump);
int20;
}
else if (key == SCAN_F10)
@ -363,6 +362,7 @@ unsigned convert(u32 keypressed)
__attribute__((interrupt)) void keyboard_handler(exception_stack_noerror *caller)
{
cli();
u8 scancode, ascii;
while ((inb(0x64) & 1) == 0);
scancode = inb(0x60);
@ -375,6 +375,7 @@ __attribute__((interrupt)) void keyboard_handler(exception_stack_noerror *caller
bufferascii[ptrascii] = ascii;
}
irqendmaster();
sti();
}
/******************************************************************************/

View File

@ -66,6 +66,7 @@ void outmsecmd(u8 command)
__attribute__((interrupt)) void mouse_handler(exception_stack_noerror *caller)
{
cli();
u8 mbyte = inb(0x60);
s8 changex, changey;
@ -142,6 +143,7 @@ __attribute__((interrupt)) void mouse_handler(exception_stack_noerror *caller)
endofint:
irqendmaster();
irqendslave();
sti();
}
/*******************************************************************************/

View File

@ -76,8 +76,10 @@ END */
void processexit(void)
{
cli();
deleteprocess(getcurrentpid());
switchtask(maketid(1,1));
sti();
}
/*******************************************************************************/
@ -257,6 +259,7 @@ process* findcurrentprocess(void)
void switchtask(tid_t tid)
{
cli();
tid_t previous = current;
task *atask = findtask(tid);
if (atask==NULL) return;
@ -346,6 +349,7 @@ task* findcurrenttask(void)
void deletetask(tid_t tid)
{
cli();
stoptask(tid);
process* aprocess=findprocess(tid.pid);
if (aprocess==NULL) return;
@ -353,6 +357,7 @@ void deletetask(tid_t tid)
if (atask==NULL) return;
TAILQ_REMOVE(&aprocess->task_head, atask, tailq);
vfree(atask);
sti();
}
/*******************************************************************************/
@ -360,6 +365,7 @@ void deletetask(tid_t tid)
void runtask(tid_t tid)
{
cli();
task *atask=findtask(tid);
if (atask==NULL) return;
if (atask->status == TASK_STATUS_READY)
@ -367,6 +373,7 @@ void runtask(tid_t tid)
atask->status = TASK_STATUS_RUN;
switchtask(tid);
}
sti();
}
/*******************************************************************************/
@ -374,6 +381,7 @@ void runtask(tid_t tid)
tid_t createtask(pid_t pid,u8 *entry, bool kerneltask)
{
cli();
tid_t tid;
tid.pid=pid;
process* aprocess=findprocess(pid);
@ -429,6 +437,7 @@ tid_t createtask(pid_t pid,u8 *entry, bool kerneltask)
new->dump.edi = 0;
new->status = TASK_STATUS_READY;
return new->tid;
sti();
}
/*******************************************************************************/
@ -436,9 +445,11 @@ tid_t createtask(pid_t pid,u8 *entry, bool kerneltask)
void stoptask(tid_t tid)
{
cli();
task *atask=findtask(tid);
if (atask==NULL) return;
atask->status=TASK_STATUS_STOP;
sti();
}
/*******************************************************************************/
@ -446,6 +457,7 @@ void stoptask(tid_t tid)
pid_t createprocess(u8 *src, bool kerneltask)
{
cli();
tid_t previous = current;
current.pid = getfreepid();
current.number = 0;
@ -467,6 +479,7 @@ pid_t createprocess(u8 *src, bool kerneltask)
cr3=old->pdd->addr->paddr;
setCR3(cr3);
new->status=PROCESS_STATUS_READY;
sti();
return new->pid;
}
@ -475,6 +488,7 @@ pid_t createprocess(u8 *src, bool kerneltask)
void deleteprocess(pid_t pid)
{
cli();
stopprocess(pid);
process* aprocess=findprocess(pid);
if (aprocess==NULL) return;
@ -482,7 +496,7 @@ void deleteprocess(pid_t pid)
TAILQ_FOREACH(next, &aprocess->task_head, tailq)
deletetask(next->tid);
aprocess->status = PROCESS_STATUS_FREE;
sti();
}
/*******************************************************************************/
@ -490,6 +504,7 @@ void deleteprocess(pid_t pid)
void runprocess(pid_t pid)
{
cli();
process* aprocess=findprocess(pid);
if (aprocess==NULL) return;
if (aprocess->status == PROCESS_STATUS_READY)
@ -501,6 +516,7 @@ void runprocess(pid_t pid)
atask->status=TASK_STATUS_RUN;
switchtask(tid);
}
sti();
}
/*******************************************************************************/

View File

@ -449,8 +449,7 @@ int showinfo()
int showregs()
{
regs dump;
show_cpu(&dump);
int20;
return 0;
}

View File

@ -10,7 +10,7 @@ void main(void)
{
while (true)
{
if (getticks()%10==0)
if (getticks()%100000==0)
print("[TEST]\r\n");
}
exit(1);

View File

@ -26,6 +26,7 @@ static u8 errormsg[] =
static u8 key = 0;
extern wrapper_timer;
extern wrapper_interruption20;
void ok()
{
@ -77,6 +78,8 @@ int main(u32 magic, u32 addr)
print("\033[37m\033[0m -Initilisation des interruptions");
initidt();
initpic();
setidt((u32) &wrapper_interruption20, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING3 | TRAPGATE, 20);
sti();
ok();