Why the memory cannot be written?
Posted: Sat Jul 04, 2020 11:27 am
I have already implemented physic allocation and paging. But I found otherwise I got the right virtual address of the memory, I cannot write the memory.
It's my testing code, physic_alloc will return physic address of page(s) witch can fit request size.
And interrupt is active, paging fault handler also is setted.
The testing outputs no error or exception, but
In another test, I try to set value of members of a struct, but there is no effect.
The target address, 0xe00d9000, its page directory entry is
page entry is
So the paging target is right, and RW bit is true, why the page cannot be wrote?
It's my code to enable paging. 0x00000000 -> 0xC0000000
It's my testing code, physic_alloc will return physic address of page(s) witch can fit request size.
And interrupt is active, paging fault handler also is setted.
Code: Select all
int* arr = (int*) ((uint32_t)physic_alloc(45*sizeof(int)) + PAGE_OFFSET);
for(int i = 0; i<12; ++i) {
arr[i] = i;
}
for(int i = 0; i<12; ++i) {
printf("%d\n", arr[i]);
}
arr[2] = 4;
Code: Select all
0
0
0
... ('0' * 12)
The target address, 0xe00d9000, its page directory entry is
Code: Select all
pdg_k[0x380] = 0x18e003
Code: Select all
tables[0x80][0xd9] = 0x200d9003
It's my code to enable paging. 0x00000000 -> 0xC0000000
Code: Select all
uint32_t cr0;
asm volatile ("mov %%cr0, %0" : "=r" (cr0));
cr0 |= 0x80000000;
asm volatile ("mov %0, %%cr0" : : "r" (cr0));