flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Problems with Paging

Author
Thread Post new topic Reply to topic
joachim_neu



Joined: 22 Dec 2003
Posts: 139
joachim_neu
hello everybody,

i'm now trying to implement paging for my OS. this is the way i want like it to run:

every task has his own pagetables and pagedir. in kernelspace exists a stack whatin all free pages are pushed. all the pages which are not set with the programm are not present. i added 2 new meanings for 2 of the 3 free bits in an entry:
(this are the 3 free bits)
Code:
+-+-+-+
|0|F|S|
+-+-+-+
F shows if the page is swappable (0) or not (1)
S shows if the page is swapped (1) or not (0)
    

so if a programm reads or writes something into a not allocated part, pagefaultint will be started and try to get a page from the free stack and put it in. therefore i wrote a function which gives me the absolut adress of the pagetableentry in cr2. the pagedir in cr3 is used.
this is my pagefaultint:
Code:
int0x0E:
;page-fault-exception
push eax
push edi
push esi
call GetPageOffset
mov esi,eax
mov edi,eax
lodsd
push eax
shl eax,0x16
shr eax,0x1F
cmp eax,0x01
je int0x0E_swapped
pop eax

mov [paging_save_esp],esp ;save actual esp
mov esp,[paging_esp] ;get pagestackesp
pop eax ,get page
mov [paging_esp],esp ;save new pagestackesp
mov esp,[paging_save_esp] ;get old stackesp
add eax,0x00000003 ;set bits
stosd

pop esi
pop edi
pop eax
iret
int0x0E_swapped:
;comes later!                    
    


problem: the code doesn't work! bochs crashs with this:
Quote:

00005008698p[CPU ] >>PANIC<< fetch_raw_descriptor: LDTR.valid=0
00005008698i[SYS ] Last time is 1109097285
00005008698i[CPU ] protected mode
00005008698i[CPU ] CS.d_b = 32 bit
00005008698i[CPU ] SS.d_b = 32 bit
00005008698i[CPU ] | EAX=000000ff EBX=1000174d ECX=ffff0c00 EDX=00000300
00005008698i[CPU ] | ESP=0009ffef EBP=00000000 ESI=0009ffff EDI=01000000
00005008698i[CPU ] | IOPL=0 NV UP DI PL NZ NA PE NC
00005008698i[CPU ] | SEG selector base limit G D
00005008698i[CPU ] | SEG sltr(index|ti|rpl) base limit G D
00005008698i[CPU ] | DS:0030( 0006| 0| 0) 00000000 000fffff 1 1
00005008698i[CPU ] | ES:0030( 0006| 0| 0) 00000000 000fffff 1 1
00005008698i[CPU ] | FS:0030( 0006| 0| 0) 00000000 000fffff 1 1
00005008698i[CPU ] | GS:0030( 0006| 0| 0) 00000000 000fffff 1 1
00005008698i[CPU ] | SS:0010( 0002| 0| 0) 00000000 00000c00 1 1
00005008698i[CPU ] | CS:0008( 0001| 0| 0) 00000000 00000c00 1 1
00005008698i[CPU ] | EIP=000009f8 (000009f7)
00005008698i[CPU ] | CR0=0xe0000011 CR1=0x00000000 CR2=0x01000000
00005008698i[CPU ] | CR3=0x00003000 CR4=0x00000000
00005008698i[ ] restoring default signal behavior
00005008698i[CTRL ] quit_sim called with exit code 1


i hope anyone can help me! thank you.

J!N
Post 23 Feb 2005, 13:27
View user's profile Send private message Visit poster's website Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias
Well, first of all, I cannot help you, since I know nothing of the emulator you are using. So, having clarified at the outset that this response is essentially useless, allow me to make one observation:
PAGING is obsolete, and has been for a decade.
It has its origin in the 1970's when memory and hard disk capacity were both infinitesimally smaller than today.
You have easily, even on the slowest computer, tens or hundreds, or even thousands of megabytes of memory, just sitting there. USE IT!
No need to swap out to hard disk just a small portion of the data on your drive. MOST SOFTWARE IS POORLY WRITTEN. MOST SOFTWARE IS BASED UPON DESIGNS from thirty years ago. Forget about paging. You are wasting your time. Improve your own fledgling operating system to require a gigabyte of memory, and you can run TCP/IP and download amazing quantities of data before you will need to overwrite some portion of the memory. Smile
Post 24 Feb 2005, 11:30
View user's profile Send private message Reply with quote
bogdanontanu



Joined: 07 Jan 2004
Posts: 403
Location: Sol. Earth. Europe. Romania. Bucuresti
bogdanontanu
Man, i think he is talking about PAGING for memory management and relocation in protected mode Very Happy

And i do not think you can convince him that that kind of paging is obsolete Razz
Post 24 Feb 2005, 14:27
View user's profile Send private message Visit poster's website Reply with quote
joachim_neu



Joined: 22 Dec 2003
Posts: 139
joachim_neu
I'm talking about the paging in the PM with pagedirs and pagetables and TLB and so on. i'm using bochs as emulator.
Post 24 Feb 2005, 15:45
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Paging (as in per-page protection and task separation, not necessarily swapping to disk) certainly isn't obsolete - it's what gives you the most fine-grained and flexible protection.
Post 24 Feb 2005, 16:41
View user's profile Send private message Visit poster's website Reply with quote
joachim_neu



Joined: 22 Dec 2003
Posts: 139
joachim_neu
the problem is solved. it was because the CPU pushs a dword with a error code and i didn't know. so i changed and now it runs!
Post 26 Feb 2005, 14:41
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.