flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > paging ? Goto page 1, 2, 3, 4 Next |
Author |
|
revolution 31 Dec 2009, 21:27
First thing to do is to eliminate the effects of segments and make them all 4GB. That way you can use paging in its pure form without the abomination of segments to confuse things.
|
|||
31 Dec 2009, 21:27 |
|
dosin 31 Dec 2009, 22:00
I have been looking over this:
http://wiki.osdev.org/Paging and looking for more tuts.. to post.. will have some code posted soon.. Should paging be enabled before entering PM.. or can it be done in pm ? From these examples looks like there in PM.. The 1st one I have was based off menuette.. and enables it before pm.. Quote:
are your refering to making the segments all 4GB? |
|||
31 Dec 2009, 22:00 |
|
ManOfSteel 31 Dec 2009, 22:40
Yes, that's what he's referring to. For a flat 4GB memory with all segments overlapping, simply set all your PM segments' bases to 0 and limits to the maximum, in the segment descriptors, in the GDT.
For paging, first enable PM, initialize your page hierarchy (directory, tables, etc.), load the PD in cr3 and finally enable paging. The OSDev wiki page you linked shows that quite well. |
|||
31 Dec 2009, 22:40 |
|
dosin 31 Dec 2009, 23:05
Thanks for explaining..
Yes - I have set all my base to 0 and 0xFFFF for the limit.. I was just making sure I understood what rev was saying.. and thanks for the link! example: Is this what the layout of the page dir and table would look like? Code: Table Dir starts at 0x4000 cleared and set to not present: [0x00000002] [0x00000002] [0x00000002] [0x00000002] cont.. table starting 0x5000: should look like this [0x00000003] [0x00001003] [0x00002003] [0x00003003] cont... When I move this table address to the table dir [0x00005003] [0x00000002] [0x00000002] [0x00000002] [0x00000002] This is what I am seeing with the C code.. would this be correct? Last edited by dosin on 18 Jan 2010, 04:37; edited 1 time in total |
|||
31 Dec 2009, 23:05 |
|
egos 06 Jan 2010, 07:19
Wath strange flag values are you using? Read-only global pages, not-present "global pages", valid page dir entry with active global flag...
|
|||
06 Jan 2010, 07:19 |
|
Dex4u 06 Jan 2010, 21:09
This tells you the basics http://www.rohitab.com/discuss/index.php?showtopic=31139
Last edited by Dex4u on 07 Jan 2010, 02:23; edited 1 time in total |
|||
06 Jan 2010, 21:09 |
|
egos 07 Jan 2010, 01:35
Yes, recursive page dir mapping...
I wrote: is professional solution. But one should remember that this technology requires a kernel protection on PDE level. Else user space will be invalid. In this case page dir entry with active global flag could be useful, if it describes page tab for total 4 mb global region (all valid page tab entries have active global flag too). |
|||
07 Jan 2010, 01:35 |
|
dosin 07 Jan 2010, 22:25
Code: Wath strange flag values are you using? Read-only global pages, not-present "global pages", valid page dir entry with active global flag... yes in that C++ example.. it sets to not present page dir... when the table is added to the dir.. it set the bits to R/W present to the dir.. setting the bits to 11.. according to the example.. The point of drawing it out like that was.. trying to visualize what the code is doing.. Its basicly causing confusion for me- between looking at the manual and what bits need to be set and what was in the example.. Dex - Thanks - I have been reading that article... |
|||
07 Jan 2010, 22:25 |
|
dosin 08 Jan 2010, 18:45
What would this be in Fasm?
Code: addr &= ~0xFFF; would it = this? Code: ;eax = addr mov ebx,0xFFF not ebx and eax,ebx |
|||
08 Jan 2010, 18:45 |
|
LocoDelAssembly 08 Jan 2010, 19:00
Or just:
Code: and eax, not 0xFFF ; Is assembled as AND EAX, 0xFFFFF000 The C compiler is very likely to generate the same code as above. |
|||
08 Jan 2010, 19:00 |
|
dosin 08 Jan 2010, 19:16
cool Thanks.. That is easier..
Code: //align address to 4k (highest 20-bits of address) addr &= ~0xFFF; pginf.pagetable = addr / 0x400000; // each page table covers 0x400000 bytes in memory pginf.page = (addr % 0x400000) / 0x1000; //0x1000 = page size return pginf; } converted to: Code: ;******************* ;eax = Virtual Addres ;returns: ;eax = page table ;ebx = page ;******************* mm_virtaddrtopageindex: and eax, not 0xFFF mov ebx,eax shr eax,22 shl ebx,10 shr ebx,22 ret |
|||
08 Jan 2010, 19:16 |
|
LocoDelAssembly 08 Jan 2010, 20:11
Perhaps this is equivalent too?
Code: mm_virtaddrtopageindex: shr eax, 12 mov ebx,eax shr eax,10 and ebx, 3FF ret |
|||
08 Jan 2010, 20:11 |
|
dosin 09 Jan 2010, 01:18
I am going to attempt to convert the tutorial to asm code...
Though some funcions memset and mm_allocphyspage() are not in this code.. but I do have my own memset and allocate_mem.. but this is the next peice to convert... will post asm code prob sometime on monday... if anyone is interested... Thought it may help me and possible people new to paging.. once done I will remove the c++ versions - with asm only... from: http://www.rohitab.com/discuss/index.php?showtopic=31139 Code: set if(page_directory[890] & 1){ // page table exists, continue as we did earlier unsigned long *page_table = (unsigned long *) page_directory[890] & 0xFFFFF000; page_table[727] = 0x00012000 | 3; }else{ // page table doesn’t exist, so create one unsigned long *page_table = (unsigned long *) mm_allocphyspage(); memsetl(page_table, 2, 1024); // set 1024 dwords to 2 (r/w, not present) page_table[727] = 0x00012000 | 3; } Last edited by dosin on 09 Jan 2010, 13:39; edited 1 time in total |
|||
09 Jan 2010, 01:18 |
|
egos 09 Jan 2010, 11:24
Where is in else-block the command for putting page tab address and flags into page dir? And use recursive page dir mapping structures (total 4 mb page tab and page dir as its part) else our discussion will be abstract.
|
|||
09 Jan 2010, 11:24 |
|
dosin 11 Jan 2010, 19:27
I am starting to convert: now for the 1st if statement:
This one I am not sure on the conversion.. but I post for sugestions.. Code: ;This is conversion of the last post of C code above ;page_directory = 0x10000 ;set asside an address for the page dir ;page_table dw 0 ckforpage: mov eax,dword[page_directory+890*4] cmp al,00 jne page_exist ;esle does not exist create it call malloc_page ; returns addres in eax mov dword[eax],page_table mov esi,page_table mov eax,2 ;set bits mov ecx,1024 ;1024 dwords to set call mem_set mov dword[page_table*727+4], 0x00012000 or 3; jmp if_fin page_exist: ;page exists and eax,0xFFFFF000 mov dword[eax],page_table mov dword[page_table+727*4],0x00012000 or 3 if_fin : ret Last edited by dosin on 12 Jan 2010, 01:53; edited 4 times in total |
|||
11 Jan 2010, 19:27 |
|
egos 11 Jan 2010, 21:42
No comments...
|
|||
11 Jan 2010, 21:42 |
|
dosin 12 Jan 2010, 02:03
Then why post ..
At least be constuctive or offer some advise... |
|||
12 Jan 2010, 02:03 |
|
egos 12 Jan 2010, 07:42
C code in the article is an algorithm, not a program. You need the function for page mapping.
|
|||
12 Jan 2010, 07:42 |
|
egos 12 Jan 2010, 09:55
Code: ; eax = virt. addr. for mapped page; PDir = virt. addr. of page dir; PTab = virt. addr. of total 4 mb page tabMapPage:push eaxmov edi,eaxshr edi,22 ; index in PDirmov esi,eaxshr esi,12 ; index in PTabtest byte [PDir+edi*4],1jnz @fcall GetZeroedPageadd eax,PDE_FLAGSmov [PDir+edi*4],eax@@:test byte [PTab+esi*4],1jnz @fcall GetPageadd eax,PTE_FLAGSmov [PTab+esi*4],eaxinc [PTabCounters+edi*2] ; can be useful for unmapping@@:pop eaxret |
|||
12 Jan 2010, 09:55 |
|
Goto page 1, 2, 3, 4 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.