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
Page Fault
- piranha
- Member
- Posts: 1391
- Joined: Thu Dec 21, 2006 7:42 pm
- Location: Unknown. Momentum is pretty certain, however.
- Contact:
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?
2) This is the latest (User-Mode) tutorial, right?
3) When does this pagefault happen?
4) What info does it give?
-JLJamesM'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!
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
-
- Member
- Posts: 48
- Joined: Mon Aug 13, 2007 2:30 pm
1) I am using the same code, except for the code to display the string using the system callpiranha 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?
-JLJamesM'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!
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
- piranha
- Member
- Posts: 1391
- Joined: Thu Dec 21, 2006 7:42 pm
- Location: Unknown. Momentum is pretty certain, however.
- Contact:
Is the code that you've written good?
-JL
-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
-
- Member
- Posts: 48
- Joined: Mon Aug 13, 2007 2:30 pm
Here it is:piranha wrote:Is the code that you've written good?
-JL
In boot.asm
Code: Select all
global _testMonitorWriteSysCall
int80h_eax0: db 'Int 80h EAX=0 Called...',23
_testMonitorWriteSysCall:
mov eax, 0
mov ebx, int80h_eax0
int 80h
Code: Select all
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;
}
-
- Member
- Posts: 48
- Joined: Mon Aug 13, 2007 2:30 pm
No that is not a valid address. Now it is working, so it seems I have somehow fixed the problem.JamesM wrote:Hi,
Do you think that 0x2d2d2d2d is a valid address?Here is the info it gives: "Page fault! (present user-mode ) at 0x0x2d2d2d2d -EIP: 0x100050"
The EIP is 0x100050 - so what code is it executing? Have you disassembled the binary (objdump -d kernel)
Cheers,
James
Thanks,
Joseph