Now I use these declarations:
Code: Select all
extern unsigned long read_cr0(void);
extern void write_cr0(unsigned long);
extern unsigned long read_cr3(void);
extern void write_cr3(unsigned long);
The kernel now compiles, but it gives out warnings:
memory.c: In function `enable_paging':
memory.c:45: warning: assignment makes integer from pointer without a cast
memory.c:54: warning: passing arg 1 of `write_cr3' makes integer from pointer without a cast
The code for my function is:
Code: Select all
void enable_paging()
{
unsigned long *page_directory = (unsigned long *)0x9C00;
unsigned long *page_table = (unsigned long *)0x9D00;
unsigned long address = 0;
unsigned int i;
//Map first 4MB of memory
for (i = 0; i < 1024; i++)
{
page_table[i] = address | 3;
address = address + 4096;
};
// fill the first entry of the page directory
!!Line 45: page_directory[0] = page_table;
page_directory[0] = page_directory[0] | 3; // supervisor level, read/write, present
// Fill in the other 1023 entries
for (i = 1; i < 1024; i++)
{
page_directory[i] = 0 | 2; // supervisor level, read/write, not present
};
!!Line 54: write_cr3(page_directory); // page directory address into CR3
write_cr0(read_cr0() | 0x80000000); // set paging bit in CRO to 1
}
The read_cr0() extern declaration works fine, thanks.
I mean, the arguments *must* be unsigned long, mustn't they? A char * pointer wouldn't make sense at all... I've already tried changing the argument to unsigned long *, but it just produced more warnings than before...
Candamir