2018-09-28 20:35:51 +02:00
|
|
|
/*******************************************************************************/
|
|
|
|
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
|
|
|
|
/* */
|
2018-09-18 14:29:35 +02:00
|
|
|
#include <types.h>
|
2018-09-27 17:47:27 +02:00
|
|
|
#include <gdt.h>
|
|
|
|
#include <asm.h>
|
2018-10-02 02:16:14 +02:00
|
|
|
#include <memory.h>
|
2018-12-05 16:42:25 +01:00
|
|
|
#include <interrupts.h>
|
|
|
|
#include <syscall.h>
|
2018-09-18 14:29:35 +02:00
|
|
|
|
2018-09-18 15:11:50 +02:00
|
|
|
/* 32bit SYSENTER instruction entry.
|
2018-09-27 17:47:27 +02:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* %eax System call number.
|
|
|
|
* %ebx Arg1
|
|
|
|
* %ecx Arg2
|
|
|
|
* %edx Arg3
|
|
|
|
* %esi Arg4
|
|
|
|
* %edi Arg5
|
|
|
|
* %ebp user stack
|
|
|
|
* 0(%ebp) Arg6*/
|
2018-09-18 15:11:50 +02:00
|
|
|
|
2018-09-18 14:29:35 +02:00
|
|
|
/*******************************************************************************/
|
|
|
|
|
|
|
|
/* Entrée pour les appels système SYSENTER */
|
|
|
|
|
|
|
|
void sysenter_handler(void)
|
2018-12-05 16:42:25 +01:00
|
|
|
{
|
|
|
|
cli();
|
2018-12-09 00:40:25 +01:00
|
|
|
regs *dump;
|
2018-12-05 16:42:25 +01:00
|
|
|
dumpcpu();
|
|
|
|
getESP(dump);
|
|
|
|
sti();
|
|
|
|
switch (dump->eax)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
printf("Test de fonctionnement syscall\r\n -arguments 1:%Y 2:%Y 3:%Y\r\n", dump->ebx,dump->esi,dump->edi);
|
|
|
|
dump->eax=0x6666666;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("Appel syscall vers fonction inexistante en %Y:%Y", dump->cs,dump->eip);
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2018-12-12 00:15:36 +01:00
|
|
|
restdebugcpu();
|
2018-12-05 16:42:25 +01:00
|
|
|
sysexit();
|
2018-09-18 14:29:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
|
|
|
/* Initialise les appels système par SYSENTER/SYSEXIT */
|
|
|
|
|
|
|
|
void initsyscall(void)
|
|
|
|
{
|
2018-09-27 17:47:27 +02:00
|
|
|
wrmsr(0x174, SEL_KERNEL_CODE, 0x0);
|
2018-12-05 16:42:25 +01:00
|
|
|
wrmsr(0x175, 0x60000, 0x0);
|
|
|
|
wrmsr(0x176, &sysenter_handler+6, 0x0);
|
2018-09-18 14:29:35 +02:00
|
|
|
}
|
2018-09-28 20:35:51 +02:00
|
|
|
|
|
|
|
/*******************************************************************************/
|