Page 1 of 1

Copy physical frame

Posted: Tue Aug 26, 2008 5:39 am
by ChristianF
Hi,
i finished my physical and virtual memory manager right now.
So I searched a way how to implement a function called copy_physical_page, which should copy a physical Page. I found the Tutorial from JamesM, it was at the Multitasking-Part, but I don't like this way.
Could you tell me some possible Ways to copy a page without switching back to realmode?

Cheers Christian

Re: Copy physical frame

Posted: Tue Aug 26, 2008 5:50 am
by Kieran
Why the change to real mode, you have access to the page data in protected mode, dont you :?:

Re: Copy physical frame

Posted: Tue Aug 26, 2008 6:01 am
by ChristianF
I thought that too...
...but when I understand this Tutorial correctly: JamesM's Multitasking Tutorial (Point 9.2.3), I have to switch back to Real Mode to copy a physical frame.

May be I am misunderstanding something :lol:

Cheers Christian

Re: Copy physical frame

Posted: Tue Aug 26, 2008 6:09 am
by xyzzy
JamesM's code doesn't switch to real mode. It remains in protected mode, but disables paging temporarily so that you have access to the physical address space. This method won't work without some extra work if your kernel's virtual location is different to its physical location.

An alternate method would be to map both pages somewhere in the virtual address space, copy the contents, and then unmap them.

Re: Copy physical frame

Posted: Tue Aug 26, 2008 7:25 am
by ChristianF
Sorry.
I meant turning off Paging, not switching back to real mode #-o

So I could copy it easily for example with memcpy like this?

Code: Select all

#define PAGE_SIZE 0x1000
//memcpy(virtual_address_dest, virtual_address_src, 0x1000);
memcpy(0xD0001000, 0xD0008000, PAGE_SIZE);

So I understand it now.
Thanks for the help.

Cheers Christian