Paging initialization:
Posted: Sat Feb 08, 2003 5:42 am
Hey folks, I am kinda stuck!
I am now to build the memory management module for my kernel-experiment. I have read some sources and some information material, but to get it work is still something different. so this is what
I want to do to initialize my pagetables and to get some bookkeeping about them:
these are the book keeping structures:
typedef struct{
ulong_t block_adresse;
uint_t block_laenge;
int block_belegt; // 1=belegt, 0=nicht belegt -> info about used blocks
} speicherseite; -> the pageframe
struct speicher_verwaltung{
speicherseite *block; //a pointer to scroll an easy way throu an huge array
speicherseite seite[MEM_GROESSE]; -> the array of pageframes. assume mem groesse is about 8192.
};
the page directory:
ulong_t *page_directory = (ulong_t *) 0x40000;
ulong_t *page_tabelle[NR_PAGEFRAMES]; ->NR_PAGEFRAMES= 1024
Here is the code in question which does not what i expect it to do:
void page_tabellen_ausfuellen(){
ulong_t adresse = 0;
ulong_t *page_table_address = (ulong_t *) 0x41000;
uint_t q; uint_t z;
speichertabelle.block=&speichertabelle.seite[0];
adresse=0;
for(q=0;q<8;q++){
for(z=0;z<1024;z++){ page_tabelle[q][z]=adresse|PAGE_ATTRIBUT_SUPERVISOR_RW_VORHANDEN;
speichertabelle.block->block_adresse=adresse;
speichertabelle.block->block_laenge=4096;
speichertabelle.block->block_belegt=0;
speichertabelle.block++;
adresse+=4096;
}
page_table_address=page_table_address+4096;
*page_tabelle=(ulong_t *)page_table_address;
}
after this code I fill in the page directory:
for(q=0;q<8;q++){
page_directory[q]=*page_tabelle[q]|PAGEATTRIBUT; -> SUper visor present
}
for(q=8;q<1024;q++){
page_directory[q]=0|PAGEATTRIBUT ;-> Supervisor not present
}
}
this should be the initialization routine for setting up the paging structures. but I have the feeling as if there is something wrong, But I just can't find it. It throws an exception to be exactly.and after that it triple faults.
could you guys pls help me out of that?
stay safe.
I am now to build the memory management module for my kernel-experiment. I have read some sources and some information material, but to get it work is still something different. so this is what
I want to do to initialize my pagetables and to get some bookkeeping about them:
these are the book keeping structures:
typedef struct{
ulong_t block_adresse;
uint_t block_laenge;
int block_belegt; // 1=belegt, 0=nicht belegt -> info about used blocks
} speicherseite; -> the pageframe
struct speicher_verwaltung{
speicherseite *block; //a pointer to scroll an easy way throu an huge array
speicherseite seite[MEM_GROESSE]; -> the array of pageframes. assume mem groesse is about 8192.
};
the page directory:
ulong_t *page_directory = (ulong_t *) 0x40000;
ulong_t *page_tabelle[NR_PAGEFRAMES]; ->NR_PAGEFRAMES= 1024
Here is the code in question which does not what i expect it to do:
void page_tabellen_ausfuellen(){
ulong_t adresse = 0;
ulong_t *page_table_address = (ulong_t *) 0x41000;
uint_t q; uint_t z;
speichertabelle.block=&speichertabelle.seite[0];
adresse=0;
for(q=0;q<8;q++){
for(z=0;z<1024;z++){ page_tabelle[q][z]=adresse|PAGE_ATTRIBUT_SUPERVISOR_RW_VORHANDEN;
speichertabelle.block->block_adresse=adresse;
speichertabelle.block->block_laenge=4096;
speichertabelle.block->block_belegt=0;
speichertabelle.block++;
adresse+=4096;
}
page_table_address=page_table_address+4096;
*page_tabelle=(ulong_t *)page_table_address;
}
after this code I fill in the page directory:
for(q=0;q<8;q++){
page_directory[q]=*page_tabelle[q]|PAGEATTRIBUT; -> SUper visor present
}
for(q=8;q<1024;q++){
page_directory[q]=0|PAGEATTRIBUT ;-> Supervisor not present
}
}
this should be the initialization routine for setting up the paging structures. but I have the feeling as if there is something wrong, But I just can't find it. It throws an exception to be exactly.and after that it triple faults.
could you guys pls help me out of that?
stay safe.