Copy physical frame

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
ChristianF
Member
Member
Posts: 79
Joined: Sun Jun 10, 2007 11:36 am

Copy physical frame

Post 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
Kieran
Member
Member
Posts: 54
Joined: Mon Apr 11, 2005 11:00 pm

Re: Copy physical frame

Post by Kieran »

Why the change to real mode, you have access to the page data in protected mode, dont you :?:
ChristianF
Member
Member
Posts: 79
Joined: Sun Jun 10, 2007 11:36 am

Re: Copy physical frame

Post 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
xyzzy
Member
Member
Posts: 391
Joined: Wed Jul 25, 2007 8:45 am
Libera.chat IRC: aejsmith
Location: London, UK
Contact:

Re: Copy physical frame

Post 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.
ChristianF
Member
Member
Posts: 79
Joined: Sun Jun 10, 2007 11:36 am

Re: Copy physical frame

Post 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
42
Post Reply