feat: ajout d'une commande MEM et de plusieurs fonctions donnant des indications sur la mémoire
This commit is contained in:
parent
4a6b7542fc
commit
4f92e419e2
|
@ -153,6 +153,7 @@ Pour l'instant quelques commandes seulement sont disponibles:
|
||||||
* REGS affiche les registres CPU,
|
* REGS affiche les registres CPU,
|
||||||
* GDT affiche la table des descripteurs,
|
* GDT affiche la table des descripteurs,
|
||||||
* IDT affiche la table des interruptions,
|
* IDT affiche la table des interruptions,
|
||||||
|
* MEM affiche les statistiques d'occupation memoire,
|
||||||
* INFO affiche des informations issues de GRUB,
|
* INFO affiche des informations issues de GRUB,
|
||||||
* ERR génère une exception (ARGUMENTS),
|
* ERR génère une exception (ARGUMENTS),
|
||||||
* VIEW visionne la mémoire vive (ARGUMENTS),
|
* VIEW visionne la mémoire vive (ARGUMENTS),
|
||||||
|
|
|
@ -107,3 +107,6 @@ void virtual_range_new(pd *dst, u8 *vaddr, u64 len, u32 flags);
|
||||||
void malloc_init(void);
|
void malloc_init(void);
|
||||||
void identity_init(void);
|
void identity_init(void);
|
||||||
void registry_init(void);
|
void registry_init(void);
|
||||||
|
u32 getmallocused(void);
|
||||||
|
u32 getmallocfree(void);
|
||||||
|
u32 getmallocnonallocated(void);
|
||||||
|
|
|
@ -28,3 +28,4 @@ int sfont(u8* commandline);
|
||||||
int help();
|
int help();
|
||||||
int logo();
|
int logo();
|
||||||
int detectpci();
|
int detectpci();
|
||||||
|
int mem();
|
||||||
|
|
44
lib/memory.c
44
lib/memory.c
|
@ -37,6 +37,46 @@ tmalloc *mallocpage(u8 size)
|
||||||
return chunk;
|
return chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
/* Retourne la mémoire virtuelle utilisée de façon dynamique (heap) */
|
||||||
|
|
||||||
|
u32 getmallocused(void)
|
||||||
|
{
|
||||||
|
u32 realsize=0;
|
||||||
|
tmalloc *chunk, *new;
|
||||||
|
chunk = KERNEL_HEAP;
|
||||||
|
while (chunk < (tmalloc *) kernelcurrentheap) {
|
||||||
|
if (chunk->used)
|
||||||
|
realsize+=chunk->size;
|
||||||
|
chunk = chunk + chunk->size;
|
||||||
|
}
|
||||||
|
return realsize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
/* Retourne la mémoire virtuelle libre de façon dynamique (heap) */
|
||||||
|
|
||||||
|
u32 getmallocfree(void)
|
||||||
|
{
|
||||||
|
u32 realsize=0;
|
||||||
|
tmalloc *chunk, *new;
|
||||||
|
chunk = KERNEL_HEAP;
|
||||||
|
while (chunk < (tmalloc *) kernelcurrentheap) {
|
||||||
|
if (!chunk->used)
|
||||||
|
realsize+=chunk->size;
|
||||||
|
chunk = chunk + chunk->size;
|
||||||
|
}
|
||||||
|
return realsize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
/* Retourne la mémoire virtuelle non allouée de façon dynamique (heap) */
|
||||||
|
|
||||||
|
u32 getmallocnonallocated(void)
|
||||||
|
{
|
||||||
|
return VESA_FBMEM-((u32) kernelcurrentheap);
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************************************************************/
|
/*******************************************************************************/
|
||||||
/* Alloue de la mémoire virtuelle au noyau de façon dynamique (heap) */
|
/* Alloue de la mémoire virtuelle au noyau de façon dynamique (heap) */
|
||||||
|
|
||||||
|
@ -91,8 +131,10 @@ u64 physical_getmemorysize()
|
||||||
multiboot_memory_map_t *mmap;
|
multiboot_memory_map_t *mmap;
|
||||||
for (mmap = ((struct multiboot_tag_mmap *) tag)->entries;(u8 *) mmap < (u8 *) tag + tag->size; mmap = (multiboot_memory_map_t *)
|
for (mmap = ((struct multiboot_tag_mmap *) tag)->entries;(u8 *) mmap < (u8 *) tag + tag->size; mmap = (multiboot_memory_map_t *)
|
||||||
((unsigned long) mmap + ((struct multiboot_tag_mmap *) tag)->entry_size))
|
((unsigned long) mmap + ((struct multiboot_tag_mmap *) tag)->entry_size))
|
||||||
if (mmap->addr+mmap->len>maxaddr)
|
if ((mmap->addr+mmap->len>maxaddr) && mmap->type==1)
|
||||||
maxaddr=mmap->addr+mmap->len;
|
maxaddr=mmap->addr+mmap->len;
|
||||||
|
if (maxaddr>=MAXMEMSIZE)
|
||||||
|
maxaddr=MAXMEMSIZE-1;
|
||||||
return maxaddr;
|
return maxaddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
lib/shell.c
12
lib/shell.c
|
@ -39,6 +39,7 @@ static command commands[] = {
|
||||||
{"font" , "", &sfont},
|
{"font" , "", &sfont},
|
||||||
{"test3d" , "", &test3d},
|
{"test3d" , "", &test3d},
|
||||||
{"detectpci" , "", &detectpci},
|
{"detectpci" , "", &detectpci},
|
||||||
|
{"mem" , "", &mem},
|
||||||
};
|
};
|
||||||
|
|
||||||
/*******************************************************************************/
|
/*******************************************************************************/
|
||||||
|
@ -78,6 +79,17 @@ int test(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
/* Affiche des informations sur la mémoire */
|
||||||
|
int mem()
|
||||||
|
{
|
||||||
|
u32 libre=getmemoryfree();
|
||||||
|
u32 total=physical_getmemorysize();
|
||||||
|
printf("Memoire physique\r\n -libre : %H\r\n -occupee : %H\r\n -total : %H\r\n\r\n",libre,total-libre,total);
|
||||||
|
printf("Memoire tas noyau\r\n -libre : %H\r\n -occupee : %H\r\n -allouables : %H\r\n",getmallocfree(),getmallocused(),getmallocnonallocated());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************************************************************/
|
/*******************************************************************************/
|
||||||
/* Affiche les périphériques PCI */
|
/* Affiche les périphériques PCI */
|
||||||
int detectpci()
|
int detectpci()
|
||||||
|
|
Loading…
Reference in New Issue