My Project
Chargement...
Recherche...
Aucune correspondance
noyau
main-kmalloc.c
Aller à la documentation de ce fichier.
1
7
#include <manux/config.h>
8
#include <
manux/bootloader.h
>
9
#include <manux/errno.h>
10
#include <
manux/console.h
>
11
#include <
manux/segment.h
>
12
#include <
manux/memoire.h
>
13
#include <
manux/kmalloc.h
>
14
#include <
manux/printk.h
>
15
#include <
manux/stdlib.h
>
// rand
16
20
#define NB_ELEMENTS 200
21
#define NB_APPELS 10000
22
23
void
testerKmalloc
()
24
{
25
void
* elements[
NB_ELEMENTS
] = {
NULL
,};
26
int
n, e;
27
28
printk
(
PRINTK_DEBUGAGE
"Avant :\n"
);
29
for
(e = 0; e<
NB_ELEMENTS
; e++){
30
elements[e] =
NULL
;
31
}
32
kmallocAfficherStatistiques
(
""
);
33
for
(n = 0; n <
NB_APPELS
; n++) {
34
e =
rand
() %
NB_ELEMENTS
;
35
if
(elements[e] ==
NULL
) {
36
elements[e] =
kmalloc
(
rand
() % 1024);
37
}
else
{
38
kfree
(elements[e]);
39
elements[e] =
NULL
;
40
}
41
}
42
printk
(
PRINTK_DEBUGAGE
"Apres :\n"
);
43
kmallocAfficherStatistiques
(
""
);
44
}
45
46
void
startManuX
()
47
{
48
// Récupération des informations depuis le bootloader
49
bootloaderInitialiser
();
50
51
// Initialisation de la console noyau
52
consoleInitialisation
();
53
54
// On peut initialiser la gestion de la mémoire
55
initialiserMemoire
(
infoSysteme
.
memoireDeBase
,
56
infoSysteme
.
memoireEtendue
);
57
58
// Initialsation du système kmalloc
59
kmallocInitialisation
();
60
61
testerKmalloc
();
62
}
/* startManuX */
63
64
console.h
Définition des fonctions de base d'accés à la console.
consoleInitialisation
int consoleInitialisation(void)
Initialisation du système de console sans notion de fichier.
Definition
console.c:869
kmalloc.h
Définition de kmalloc.
memoire.h
initialiserMemoire
void initialiserMemoire(uint32_t tailleMemoireDeBase, uint32_t tailleMemoireEtendue)
Initialisation de la mémoire au niveau pages.
Definition
memoire.c:103
printk.h
Définition des fonctions de base d'entrée-sortie du noyau.
printk
void printk(char *format,...)
Fonction principale d'affichage dans le noyau.
Definition
printk.c:166
PRINTK_DEBUGAGE
#define PRINTK_DEBUGAGE
Definition
printk.h:33
NULL
#define NULL
Definition
stddef.h:10
kmallocAfficherStatistiques
void kmallocAfficherStatistiques(void)
Definition
kmalloc-zs.c:59
kmallocInitialisation
void kmallocInitialisation(void)
Initialisation du sytème kmalloc.
Definition
kmalloc-zs.c:80
kmalloc
void * kmalloc(size_t n)
Allocation d'une zone de n octets.
Definition
kmalloc-zs.c:139
kfree
void kfree(void *p)
Libération d'une zone mémoire allouée.
Definition
kmalloc-zs.c:265
startManuX
void startManuX()
Definition
main-kmalloc.c:46
NB_APPELS
#define NB_APPELS
Definition
main-kmalloc.c:21
testerKmalloc
void testerKmalloc()
Definition
main-kmalloc.c:23
NB_ELEMENTS
#define NB_ELEMENTS
Une fonction qu iinvoque kmalloc et kfree.
Definition
main-kmalloc.c:20
bootloader.h
Interfaçage avec les bootloader.
infoSysteme
InfoSysteme infoSysteme
Stockage des informations décrivant le système fournies par le bootloader.
Definition
bootloader.c:29
bootloaderInitialiser
void bootloaderInitialiser(void)
Lecture des informations fournies par le bootloader.
Definition
bootloader.c:46
stdlib.h
Définition de quelques fonctions de base (C) Manu Chaput 2020-2023.
rand
uint32_t rand(void)
Génération d'un nombre "aléatoire" entre 0 et RAND_MAX.
Definition
stdlib.c:12
segment.h
_InfoSysteme::memoireDeBase
uint32_t memoireDeBase
Definition
bootloader.h:43
_InfoSysteme::memoireEtendue
uint32_t memoireEtendue
Definition
bootloader.h:44
Généré par
1.9.8