OSDev.org

The Place to Start for Operating System Developers
It is currently Thu May 09, 2024 1:02 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Page Fault
PostPosted: Tue May 27, 2008 5:52 pm 
Offline
Member
Member

Joined: Mon Aug 13, 2007 2:30 pm
Posts: 48
I am using the tutorial JamesM has written. I am trying to do a system call, but every time I try to do int 80h in the kernel's main function with ebx set to the string to display (monitor_write system call) , I get a page fault. I am a total newbie at kernel development, but can anyone help me figure out what is wrong?

Thanks,
Joseph


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 27, 2008 8:26 pm 
Offline
Member
Member
User avatar

Joined: Thu Dec 21, 2006 7:42 pm
Posts: 1391
Location: Unknown. Momentum is pretty certain, however.
1) Are you using the exact same code as the tutorial?
2) This is the latest (User-Mode) tutorial, right?
3) When does this pagefault happen?
4) What info does it give?

JamesM's Tutorial wrote:
If you keep getting page faults when jumping to user mode, make sure that your kernel code/data is set to be user-accessible. When you actually load user programs you won't want this to be the case, however at the moment we merely jump back to the kernel and execute code in main(), so it needs to be accessible in user mode!


-JL

_________________
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 27, 2008 8:58 pm 
Offline
Member
Member

Joined: Mon Aug 13, 2007 2:30 pm
Posts: 48
piranha wrote:
1) Are you using the exact same code as the tutorial?
2) This is the latest (User-Mode) tutorial, right?
3) When does this pagefault happen?
4) What info does it give?

JamesM's Tutorial wrote:
If you keep getting page faults when jumping to user mode, make sure that your kernel code/data is set to be user-accessible. When you actually load user programs you won't want this to be the case, however at the moment we merely jump back to the kernel and execute code in main(), so it needs to be accessible in user mode!


-JL


1) I am using the same code, except for the code to display the string using the system call
2) Yes
3) It gives me the pagefault right after the int 80h system call
4)Here is the info it gives: "Page fault! (present user-mode ) at 0x0x2d2d2d2d -EIP: 0x100050"

Thanks,
Joseph


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 27, 2008 9:10 pm 
Offline
Member
Member
User avatar

Joined: Thu Dec 21, 2006 7:42 pm
Posts: 1391
Location: Unknown. Momentum is pretty certain, however.
Is the code that you've written good?

-JL

_________________
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 27, 2008 9:13 pm 
Offline
Member
Member

Joined: Mon Aug 13, 2007 2:30 pm
Posts: 48
piranha wrote:
Is the code that you've written good?

-JL


Here it is:

In boot.asm
Code:
global _testMonitorWriteSysCall

int80h_eax0:     db 'Int 80h EAX=0 Called...',23
         
_testMonitorWriteSysCall:
    mov eax, 0
    mov ebx, int80h_eax0
    int 80h


In main:
Code:
int main(struct multiboot *mboot_ptr, u32int initial_stack)
{
    page_directory_t *dir;
    initial_esp = initial_stack;
    // Initialise all the ISRs and segmentation
    init_descriptor_tables();
    // Initialise the screen (by clearing it)
    monitor_clear();

    // Initialise the PIT to 100Hz
    asm volatile("sti");
    init_timer(50);

    // Start paging.
    initialise_paging();

    // Start multitasking.
    initialise_tasking();
   
    initialise_syscalls();
   
    monitor_write(" ----------------------------------------- \n");
    monitor_write("| Welcome                                   |\n");
    monitor_write(" ----------------------------------------- \n");
   
    switch_to_user_mode();
   
    testMonitorWriteSysCall();

    return 0;
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 28, 2008 1:43 am 
Offline
Member
Member
User avatar

Joined: Tue Jul 10, 2007 5:27 am
Posts: 2935
Location: York, United Kingdom
Hi,

Quote:
Here is the info it gives: "Page fault! (present user-mode ) at 0x0x2d2d2d2d -EIP: 0x100050"


Do you think that 0x2d2d2d2d is a valid address?

The EIP is 0x100050 - so what code is it executing? Have you disassembled the binary (objdump -d kernel)

Cheers,

James

_________________
Horizon - a framework and language for SAS-OS development
Project 'Pedigree'
Practical x86 OSDev tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 28, 2008 12:15 pm 
Offline
Member
Member

Joined: Mon Aug 13, 2007 2:30 pm
Posts: 48
JamesM wrote:
Hi,

Quote:
Here is the info it gives: "Page fault! (present user-mode ) at 0x0x2d2d2d2d -EIP: 0x100050"


Do you think that 0x2d2d2d2d is a valid address?

The EIP is 0x100050 - so what code is it executing? Have you disassembled the binary (objdump -d kernel)

Cheers,

James


No that is not a valid address. Now it is working, so it seems I have somehow fixed the problem.

Thanks,
Joseph


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 54 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group