flat assembler
Message board for the users of flat assembler.

Index > OS Construction > paging ?

Goto page Previous  1, 2, 3, 4  Next
Author
Thread Post new topic Reply to topic
egos



Joined: 10 Feb 2009
Posts: 144
egos 22 Jan 2010, 19:22
Quote:
AFAIK the safest bet is to rely on BIOS function E820 to query the system memory map... or falling back to E801 (or even 88 ) if it's not available.
Yes, it's standard solution described in ACPI Spec. The info is got out of BIOS in RM and then is transferred to the PM code.
Post 22 Jan 2010, 19:22
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 22 Jan 2010, 19:25
egos wrote:
Quote:
AFAIK the safest bet is to rely on BIOS function E820 to query the system memory map... or falling back to E801 (or even 88 ) if it's not available.
Yes, it's standard solution described in ACPI Spec. The info is got out of BIOS in RM and then is transferred to the PM code.
Yup, that's how I did it in my toy kernel Smile

I've heard claims that some systems (relatively recent ones, not talking pre-90'es or anything) don't support this system call, though... dunno if it's true, and if it is, how many machines it affects (if it's limited to high-end server BIOSes or EFI systems, I guess it's not that bad Smile)

_________________
Image - carpe noctem
Post 22 Jan 2010, 19:25
View user's profile Send private message Visit poster's website Reply with quote
egos



Joined: 10 Feb 2009
Posts: 144
egos 22 Jan 2010, 20:01
Quote:
Yup, that's how I did it in my toy kernel Smile
I'm using this method too.
Post 22 Jan 2010, 20:01
View user's profile Send private message Reply with quote
dosin



Joined: 24 Aug 2007
Posts: 337
dosin 22 Jan 2010, 21:33
egos:
Quote:
Why did you this? Fill page dir with zeroes (or as I did).


was just making sure the mem used is cleared...

would it be best just to fill the page dir?

Code:
mov edi,0x5000
mov eax,0x6000
mov ecx,1024
@@: or eax,7
stosd 
add eax,4096
loop @b     
Post 22 Jan 2010, 21:33
View user's profile Send private message Reply with quote
egos



Joined: 10 Feb 2009
Posts: 144
egos 23 Jan 2010, 08:20
No. Did you understand what you did? Fill page dir with zeroes and set only that dir entries which are necessary.

Code:
  xor eax,eax
  mov ecx,1024
  mov edi,5000h
  rep stosd
  ...
  mov dword [5000h+0*4], FIRST_PAGE_TAB_ADDR or 7    
Post 23 Jan 2010, 08:20
View user's profile Send private message Reply with quote
dosin



Joined: 24 Aug 2007
Posts: 337
dosin 23 Jan 2010, 19:55
I see - I was filling all the tables - as present.. instead of 0

So I need to set the rest of the dir to 0
and just set the ones I am using to presant..

Quote:
set only that dir entries which are necessary

?
What would the min dir entries should I start with?
Post 23 Jan 2010, 19:55
View user's profile Send private message Reply with quote
egos



Joined: 10 Feb 2009
Posts: 144
egos 23 Jan 2010, 21:42
Quote:
What would the min dir entries should I start with?
1 for identity mapping (usually it is first) + 1 for recursive page dir mapping (if it is used). I wrote:
Code:
  ...
  lea eax,[edi-1000h+PAGE_LOCAL] 
  mov edi,ebx 
  stosd ; set 1st PDE
  mov ecx,1022 
  xor eax,eax 
  rep stosd 
  lea eax,[ebx+PAGE_LOCAL-PF_APL] 
  stosd ; set last PDE
  ...    
Post 23 Jan 2010, 21:42
View user's profile Send private message Reply with quote
dosin



Joined: 24 Aug 2007
Posts: 337
dosin 01 Feb 2010, 20:40
This is messed up.. I can enable paging / long mode - 4 MB ..
works perfect every test.. but my protected mode paging crashes everytime..
I can not figure out the bug..

I will prob take a break and work on the long mode for now..

unless anyone has any sugestions..
the page table and dir fill in the same way..for the 4 MB pmode or long mode paging.. the only difference is this step to enable long mode:

Code:
mov   ecx,0C0000080h  
rdmsr
or eax,1 shl 8             
wrmsr                       
    


one crashes the other works fine.. Question
Post 01 Feb 2010, 20:40
View user's profile Send private message Reply with quote
egos



Joined: 10 Feb 2009
Posts: 144
egos 06 Feb 2010, 20:55
Quote:
or do you have a small demo I could use to test...


Description: floppy image
Download
Filename: floppy.zip
Filesize: 1010 Bytes
Downloaded: 327 Time(s)

Description: source file
Download
Filename: sample.zip
Filesize: 878 Bytes
Downloaded: 306 Time(s)

Post 06 Feb 2010, 20:55
View user's profile Send private message Reply with quote
egos



Joined: 10 Feb 2009
Posts: 144
egos 10 Feb 2010, 08:25
Quote:
This is messed up.. I can enable paging / long mode - 4 MB ..
works perfect every test.. but my protected mode paging crashes everytime..
I can not figure out the bug..

I will prob take a break and work on the long mode for now..

unless anyone has any sugestions..
the page table and dir fill in the same way..for the 4 MB pmode or long mode paging.. the only difference is this step to enable long mode...
In long mode the size of large page is 2 mb, not 4 mb. 4-mb pages could be used with 36-bit physical addressing in PSE-36 mode only. To activate LM you must do more steps (not only LME setting) and use more paging structures (PML4, PDirTabs, PDirs, PTabs) with 8-byte table entries.
Post 10 Feb 2010, 08:25
View user's profile Send private message Reply with quote
dosin



Joined: 24 Aug 2007
Posts: 337
dosin 10 Feb 2010, 16:17
Thanks for the info..
with the 32 bit paging - its writing to the video mem... and displaying junk on the screen... no matter what address I chose to start the paging at... but its not crashing like it was.. even tried your example in my kernel and same thing.. fill the screen with junk...
Post 10 Feb 2010, 16:17
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak 10 Feb 2010, 20:57
egos, it would be nice if you could put comments in your source if you share it with others as a template for educational purposes.
Post 10 Feb 2010, 20:57
View user's profile Send private message Reply with quote
egos



Joined: 10 Feb 2009
Posts: 144
egos 11 Feb 2010, 09:23
My source was intended for topic starter. If you want to see my comments show me what fragment you are interested in.
Post 11 Feb 2010, 09:23
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak 11 Feb 2010, 21:12
Code:
 mov dx,03F2h
        mov al,0
    out dx,al

       cli

     mov al,8Fh
  out 70h,al
  in al,71h
    

this ports operations are new for me. could you explain this part, please?
Post 11 Feb 2010, 21:12
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 11 Feb 2010, 21:16
out(70h,8Fh) is for disabling NMIs - dunno about the rest.
Post 11 Feb 2010, 21:16
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 11 Feb 2010, 21:46
zhak,

0x03F2 port is digital output register of FDC, out(0x03F2, 0) stops drives' motors, disables DMA and resets controller.
Post 11 Feb 2010, 21:46
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak 11 Feb 2010, 23:30
heh, never worked with FDC. not surprised that i'm not familiar with this stuff Smile
Post 11 Feb 2010, 23:30
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 12 Feb 2010, 06:18
Ah yes, I see I had that 0x3F2 code in my toy kernel bootloader as well - been quite a while since I messed with it Smile. It's a good idea turning off the floppy motor if you load your kernel from floppy, before booting your kernel, otherwise you risk the light and motor keep going Smile
Post 12 Feb 2010, 06:18
View user's profile Send private message Visit poster's website Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 557
smiddy 12 Feb 2010, 11:36
f0dder wrote:
Ah yes, I see I had that 0x3F2 code in my toy kernel bootloader as well - been quite a while since I messed with it Smile. It's a good idea turning off the floppy motor if you load your kernel from floppy, before booting your kernel, otherwise you risk the light and motor keep going Smile

If I recall right, this is only if you switch processor modes. If you stay in real mode, you shouldn't need to turn the floppy off. Smile
Post 12 Feb 2010, 11:36
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 12 Feb 2010, 11:41
smiddy wrote:
If I recall right, this is only if you switch processor modes. If you stay in real mode, you shouldn't need to turn the floppy off. Smile
I would expect this is because the BIOS will do it for you.
Post 12 Feb 2010, 11: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:  
Goto page Previous  1, 2, 3, 4  Next

< 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.