fix: pS permettant de visualiser l'ensemble de tâches et processus, corrections asm.h

This commit is contained in:
Nicolas Hordé 2018-12-25 19:22:56 +01:00
parent 6776594ece
commit c894b99170
7 changed files with 31 additions and 16 deletions

View File

@ -40,19 +40,19 @@
# define irqendslave() asm("movb $0x20,%al; \ # define irqendslave() asm("movb $0x20,%al; \
outb %al,$0xA0;") outb %al,$0xA0;")
# define lidt(idtr) asm ("lidtl %0"::"m" (*idtr)) # define lidt(idtr) asm ("lidtl %0"::"m" (idtr))
# define lgdt(gdtr) asm ("lgdtl %0"::"m" (*gdtr)) # define lgdt(gdtr) asm ("lgdtl %0"::"m" (gdtr))
# define lldt(ldtr) asm ("lldtl %0"::"m" (*ldtr)) # define lldt(ldtr) asm ("lldtl %0"::"m" (ldtr))
# define ltr(tss) asm volatile ("ltr %%ax":: "a" (tss)) # define ltr(tss) asm volatile ("ltr %%ax":: "a" (tss))
# define sidt(idtr) asm ("sidtl %0"::"m" (*idtr)) # define sidt(idtr) asm ("sidtl %0"::"m" (idtr))
# define sgdt(gdtr) asm ("sgdtl %0"::"m" (*gdtr)) # define sgdt(gdtr) asm ("sgdtl %0"::"m" (gdtr))
# define sldt(ldtr) asm ("sldtl %0"::"m" (*ldtr)) # define sldt(ldtr) asm ("sldtl %0"::"m" (ldtr))
# define str(tss) asm volatile ("str %%ax;\ # define str(tss) asm volatile ("str %%ax;\
mov %%ax,%0":: "m" (tss)) mov %%ax,%0":: "m" (tss))

View File

@ -295,10 +295,10 @@ void show_cpu(regs * stack)
getdestype(tss), getdessize(tss), getdesbit3(tss), getdestype(tss), getdessize(tss), getdesbit3(tss),
getdesbit2(tss), getdesbit1(tss), getdesalign(tss)); getdesbit2(tss), getdesbit1(tss), getdesalign(tss));
struct gdtr gdtreg; struct gdtr gdtreg;
sgdt(&gdtreg); sgdt(gdtreg);
printf("GDT= %Y %Y\r\n", gdtreg.base, gdtreg.limite); printf("GDT= %Y %Y\r\n", gdtreg.base, gdtreg.limite);
struct idtr idtreg; struct idtr idtreg;
sidt(&idtreg); sidt(idtreg);
printf("IDT= %Y %Y\r\n", idtreg.base, idtreg.limite); printf("IDT= %Y %Y\r\n", idtreg.base, idtreg.limite);
printf("CR0=%Y CR2=%Y CR3=%Y CR4=%Y\r\n", stack->cr0, stack->cr2, printf("CR0=%Y CR2=%Y CR3=%Y CR4=%Y\r\n", stack->cr0, stack->cr2,
stack->cr3, stack->cr4); stack->cr3, stack->cr4);

View File

@ -41,7 +41,7 @@ void initgdt(u32 offset)
/* recopie de la GDT a son adresse */ /* recopie de la GDT a son adresse */
memcpy(&gdt, (u8 *) gdtreg.base, gdtreg.limite, 1); memcpy(&gdt, (u8 *) gdtreg.base, gdtreg.limite, 1);
/* chargement du registre GDT */ /* chargement du registre GDT */
lgdt(&gdtreg); lgdt(gdtreg);
/* initialisation des segments */ /* initialisation des segments */
initselectors(offset); initselectors(offset);
} }

View File

@ -260,7 +260,7 @@ void initidt(void)
/* recopie de la IDT a son adresse */ /* recopie de la IDT a son adresse */
memcpy(&idt, (u8 *) idtreg.base, idtreg.limite, 1); memcpy(&idt, (u8 *) idtreg.base, idtreg.limite, 1);
/* chargement du registre IDTR */ /* chargement du registre IDTR */
lidt(&idtreg); lidt(idtreg);
} }
/******************************************************************************/ /******************************************************************************/

View File

@ -602,7 +602,6 @@ void malloc_init(void)
kernelcurrentheap = KERNEL_HEAP + PAGESIZE; kernelcurrentheap = KERNEL_HEAP + PAGESIZE;
chunk->size = PAGESIZE; chunk->size = PAGESIZE;
chunk->used = 0; chunk->used = 0;
//virtual_range_new_kernel(kernelcurrentheap, chunk->size, PAGE_NOFLAG);
} }

View File

@ -160,6 +160,7 @@ void initprocesses(void)
if (aprocess==NULL) return NULL; if (aprocess==NULL) return NULL;
aprocess->pid = pid; aprocess->pid = pid;
aprocess->result = 0; aprocess->result = 0;
aprocess->pdd = NULL;
aprocess->status = PROCESS_STATUS_RUN; aprocess->status = PROCESS_STATUS_RUN;
aprocess->iskernel = true; aprocess->iskernel = true;
TAILQ_INIT(&aprocess->task_head); TAILQ_INIT(&aprocess->task_head);
@ -487,11 +488,12 @@ pid_t createprocess(u8 *src, bool kerneltask)
{ {
cli(); cli();
tid_t previous = current; tid_t previous = current;
process* oldprocess=findcurrentprocess();
current.pid = getfreepid(); current.pid = getfreepid();
current.number = 0; current.number = 0;
process* new=findcurrentprocess(); process* new=findcurrentprocess();
if (new==NULL) return NULL; if (new==NULL) return NULL;
//new->pid = current.pid; new->parent=oldprocess->pid;
new->pdd = virtual_pd_create(); new->pdd = virtual_pd_create();
TAILQ_INIT(&new->page_head); TAILQ_INIT(&new->page_head);
TAILQ_INIT(&new->task_head); TAILQ_INIT(&new->task_head);

View File

@ -92,16 +92,30 @@ int test(void)
/*******************************************************************************/ /*******************************************************************************/
/* Afiche les processus */ /* Afiche les processus */
static u8* processstatus[] = {"LIBRE","PRET ","EXEC.","PAUSE"};
static u8* taskstatus[] = {"PRET ","EXEC.","PAUSE"};
/*******************************************************************************/
/* Affiche les tâches et processus */
int ps() int ps()
{ {
print("Processus en memoire\r\n[ PID | Status |\r\n"); print("*** Processus en memoire\r\n| PID | Parent|Status|K|P.| Pages|\r\n");
process* aprocess=findprocess((pid_t)1); process* aprocess=findprocess((pid_t)1);
while(true) while(true)
{ {
printf("|%Y|%Y|\r\n",(u32)aprocess->pid,aprocess->status); printf("|%Y|%Y| %s|%c|%hh u|%Y|\r\n",(u32)aprocess->pid,(u32)aprocess->parent,processstatus[aprocess->status],(aprocess->iskernel?'X':' '),aprocess->priority,(u32)aprocess->pdd);
aprocess=getnextprocess(aprocess,PROCESS_STATUS_ALL); aprocess=getnextprocess(aprocess,PROCESS_STATUS_ALL);
if (aprocess==NULL || aprocess->pid==(pid_t)1) break; if (aprocess==NULL || aprocess->pid==(pid_t)1) break;
} }
print("\r\n\r\n*** Taches en memoire\r\n| TID | PID |Status| CS | EIP | SS | ESP |\r\n");
task* atask=findtask(maketid(1,1));
while(true)
{
printf("|%Y|%Y| %s|%hY|%Y|%hY|%Y|\r\n",(u32)atask->tid.number,(u32)atask->tid.pid,taskstatus[atask->status],atask->dump.cs,atask->dump.eip,atask->dump.ss,atask->dump.esp);
atask=getnexttask(atask,TASK_STATUS_ALL);
if (atask==NULL || atask->tid.number==1) break;
}
} }
/*******************************************************************************/ /*******************************************************************************/
@ -649,7 +663,7 @@ int showidt()
u32 index, i = 0; u32 index, i = 0;
idtdes *desc; idtdes *desc;
struct idtr idtreg; struct idtr idtreg;
sidt(&idtreg); sidt(idtreg);
printf("Information sur l'IDT\r\nAdresse:%X Limite:%hX\r\n", printf("Information sur l'IDT\r\nAdresse:%X Limite:%hX\r\n",
idtreg.base, (u32) idtreg.limite); idtreg.base, (u32) idtreg.limite);
desc = idtreg.base; desc = idtreg.base;
@ -700,7 +714,7 @@ int showgdt()
{ {
u32 index; u32 index;
struct gdtr gdtreg; struct gdtr gdtreg;
sgdt(&gdtreg); sgdt(gdtreg);
printf("Information sur la GDT\r\nAdresse:%X Limite:%hX\r\n", printf("Information sur la GDT\r\nAdresse:%X Limite:%hX\r\n",
gdtreg.base, gdtreg.limite); gdtreg.base, gdtreg.limite);
for (index = 0; index < gdtreg.limite; index += sizeof(gdtdes)) for (index = 0; index < gdtreg.limite; index += sizeof(gdtdes))