OSDev.org

The Place to Start for Operating System Developers
It is currently Fri May 17, 2024 11:03 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 34 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Really strange problem...
PostPosted: Mon Oct 20, 2008 2:35 pm 
Offline
Member
Member
User avatar

Joined: Fri Mar 17, 2006 12:00 am
Posts: 500
Location: Napoli, Italy
I've had a really strange problem while developing my floppy driver...

To recalibrate the floppy drive I do:
Code:
...

FdcMotorOn(fdc);

while(fdc->op != 0);

...

With this code, there are these bochs outs:
Code:
00075643171i[FDD  ] controller reset in software
00075769487e[CPU0 ] check_cs(0x0008): not a valid code segment !
00075769487e[CPU0 ] interrupt(): not accessable or not code segment cs=0x0008
00075769487i[CPU0 ] CPU is in protected mode (active)
00075769487i[CPU0 ] CS.d_b = 32 bit
00075769487i[CPU0 ] SS.d_b = 32 bit
00075769487i[CPU0 ] EFER   = 0x00000000
00075769487i[CPU0 ] | RAX=0000000000000001  RBX=0000000000000000
00075769487i[CPU0 ] | RCX=0000000000000730  RDX=00000000000003f2
00075769487i[CPU0 ] | RSP=00000000c004af88  RBP=00000000c004afac
00075769487i[CPU0 ] | RSI=00000000d0000560  RDI=00000000e0002031
00075769487i[CPU0 ] |  R8=0000000000000000   R9=0000000000000000
00075769487i[CPU0 ] | R10=0000000000000000  R11=0000000000000000
00075769487i[CPU0 ] | R12=0000000000000000  R13=0000000000000000
00075769487i[CPU0 ] | R14=0000000000000000  R15=0000000000000000
00075769487i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf SF zf AF pf cf
00075769487i[CPU0 ] | SEG selector     base    limit G D
00075769487i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D
00075769487i[CPU0 ] |  CS:0008( 0001| 0|  0) 00000000 000fffff 1 1
00075769487i[CPU0 ] |  DS:0010( 0002| 0|  0) 00000000 000fffff 1 1
00075769487i[CPU0 ] |  SS:0010( 0002| 0|  0) 00000000 000fffff 1 1
00075769487i[CPU0 ] |  ES:0010( 0002| 0|  0) 00000000 000fffff 1 1
00075769487i[CPU0 ] |  FS:0010( 0002| 0|  0) 00000000 000fffff 1 1
00075769487i[CPU0 ] |  GS:0010( 0002| 0|  0) 00000000 000fffff 1 1
00075769487i[CPU0 ] |  MSR_FS_BASE:0000000000000000
00075769487i[CPU0 ] |  MSR_GS_BASE:0000000000000000
00075769487i[CPU0 ] | RIP=00000000c0000149 (00000000c0000149)
00075769487i[CPU0 ] | CR0=0xe0010011 CR1=0x0 CR2=0x00000000d0004490
00075769487i[CPU0 ] | CR3=0x00003000 CR4=0x00000280
00075769487i[CPU0 ] >> iretd  : CF
00075769487p[CPU0 ] >>PANIC<< exception(): 3rd (13) exception with no resolution


Instead:
Code:
...

FdcMotorOn(fdc);
//while(fdc->op != 0);

...

With this code, the kernel continues to run without any exception, and when I shutdown Bochs there are these lines:
Code:
00102883897i[FDD  ] controller reset in software
00131377500p[XGUI ] >>PANIC<< POWER button turned off.
00131377500i[CPU0 ] CPU is in protected mode (active)
00131377500i[CPU0 ] CS.d_b = 32 bit
00131377500i[CPU0 ] SS.d_b = 32 bit
00131377500i[CPU0 ] EFER   = 0x00000000
00131377500i[CPU0 ] | RAX=0000000000000000  RBX=00000000c00514b0
00131377500i[CPU0 ] | RCX=0000000000000780  RDX=0000000000000000
00131377500i[CPU0 ] | RSP=00000000c004afb4  RBP=00000000c004afdc
00131377500i[CPU0 ] | RSI=00000000e000201d  RDI=00000000e0002031
00131377500i[CPU0 ] |  R8=0000000000000000   R9=0000000000000000
00131377500i[CPU0 ] | R10=0000000000000000  R11=0000000000000000
00131377500i[CPU0 ] | R12=0000000000000000  R13=0000000000000000
00131377500i[CPU0 ] | R14=0000000000000000  R15=0000000000000000
00131377500i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df IF tf sf ZF af PF cf
00131377500i[CPU0 ] | SEG selector     base    limit G D
00131377500i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D
00131377500i[CPU0 ] |  CS:0008( 0001| 0|  0) 00000000 000fffff 1 1
00131377500i[CPU0 ] |  DS:0010( 0002| 0|  0) 00000000 000fffff 1 1
00131377500i[CPU0 ] |  SS:0010( 0002| 0|  0) 00000000 000fffff 1 1
00131377500i[CPU0 ] |  ES:0010( 0002| 0|  0) 00000000 000fffff 1 1
00131377500i[CPU0 ] |  FS:0010( 0002| 0|  0) 00000000 000fffff 1 1
00131377500i[CPU0 ] |  GS:0010( 0002| 0|  0) 00000000 000fffff 1 1
00131377500i[CPU0 ] |  MSR_FS_BASE:0000000000000000
00131377500i[CPU0 ] |  MSR_GS_BASE:0000000000000000
00131377500i[CPU0 ] | RIP=00000000c00019aa (00000000c00019aa)
00131377500i[CPU0 ] | CR0=0xe0010011 CR1=0x0 CR2=0x00000000d0004490
00131377500i[CPU0 ] | CR3=0x00003000 CR4=0x00000280


The only differences are these:
Code:
00075769487e[CPU0 ] check_cs(0x0008): not a valid code segment !
00075769487e[CPU0 ] interrupt(): not accessable or not code segment cs=0x0008
...
00075769487i[CPU0 ] >> iretd  : CF
00075769487p[CPU0 ] >>PANIC<< exception(): 3rd (13) exception with no resolution


Why there is this exception?

_________________
Rewriting virtual memory manager - Working on ELF support - Working on Device Drivers Handling

http://sourceforge.net/projects/jeko - Jeko Operating System


Top
 Profile  
 
 Post subject: Re: Really strange problem...
PostPosted: Mon Oct 20, 2008 2:42 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
Quote:
Why there is this exception?
Quote:
check_cs(0x0008): not a valid code segment !

Bochs debugger, hint hint :wink:

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: Really strange problem...
PostPosted: Mon Oct 20, 2008 2:48 pm 
Offline
Member
Member
User avatar

Joined: Fri Mar 17, 2006 12:00 am
Posts: 500
Location: Napoli, Italy
Combuster wrote:
Bochs debugger, hint hint :wink:


How can I use it?

_________________
Rewriting virtual memory manager - Working on ELF support - Working on Device Drivers Handling

http://sourceforge.net/projects/jeko - Jeko Operating System


Top
 Profile  
 
 Post subject: Re: Really strange problem...
PostPosted: Mon Oct 20, 2008 2:53 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
Have you even tried figuring that out?

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: Really strange problem...
PostPosted: Mon Oct 20, 2008 4:03 pm 
Offline
Member
Member
User avatar

Joined: Fri Mar 17, 2006 12:00 am
Posts: 500
Location: Napoli, Italy
Thank you for your help...
Now it works, without any modification... I've changed only the bochs configuration file...
Really really strange...

Now I'll go to implement EXT3... If I'll have problems (and I'll have) I'll post here my questions... (hoping bochs won't make fun of me...)

_________________
Rewriting virtual memory manager - Working on ELF support - Working on Device Drivers Handling

http://sourceforge.net/projects/jeko - Jeko Operating System


Top
 Profile  
 
 Post subject: Re: Really strange problem...
PostPosted: Mon Oct 20, 2008 4:09 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
Jeko wrote:
(hoping bochs won't make fun of me...)
I will, for not killing temporal bugs on sight :evil:

Expect it to come back and haunt you.

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: Really strange problem...
PostPosted: Thu Oct 23, 2008 7:31 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 17, 2006 12:00 am
Posts: 500
Location: Napoli, Italy
Combuster wrote:
Expect it to come back and haunt you.


You were right...
This is my problem:
Code:
00056657374i[FDD  ] controller reset in software
00095824087i[FDD  ] io_write: config control register: 0x00
00095830533e[CPU0 ] interrupt(): not accessable or not code segment cs=0x0008
00095830533e[CPU0 ] interrupt(): not accessable or not code segment cs=0x0008
00095830533e[CPU0 ] interrupt(): not accessable or not code segment cs=0x0008
00095830533i[CPU0 ] CPU is in protected mode (active)
00095830533i[CPU0 ] CS.d_b = 32 bit
00095830533i[CPU0 ] SS.d_b = 32 bit
00095830533i[CPU0 ] EFER   = 0x00000000
00095830533i[CPU0 ] | RAX=000000000000000f  RBX=00000000c00075e9
00095830533i[CPU0 ] | RCX=00000000000006a5  RDX=00000000000003d5
00095830533i[CPU0 ] | RSP=00000000c004ae04  RBP=00000000c004ae04
00095830533i[CPU0 ] | RSI=00000000d0000af0  RDI=00000000c000798c
00095830533i[CPU0 ] |  R8=0000000000000000   R9=0000000000000000
00095830533i[CPU0 ] | R10=0000000000000000  R11=0000000000000000
00095830533i[CPU0 ] | R12=0000000000000000  R13=0000000000000000
00095830533i[CPU0 ] | R14=0000000000000000  R15=0000000000000000
00095830533i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df IF tf sf zf af PF CF
00095830533i[CPU0 ] | SEG selector     base    limit G D
00095830533i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D
00095830533i[CPU0 ] |  CS:0008( 0001| 0|  0) 00000000 000fffff 1 1
00095830533i[CPU0 ] |  DS:0010( 0002| 0|  0) 00000000 000fffff 1 1
00095830533i[CPU0 ] |  SS:0010( 0002| 0|  0) 00000000 000fffff 1 1
00095830533i[CPU0 ] |  ES:0010( 0002| 0|  0) 00000000 000fffff 1 1
00095830533i[CPU0 ] |  FS:0010( 0002| 0|  0) 00000000 000fffff 1 1
00095830533i[CPU0 ] |  GS:0010( 0002| 0|  0) 00000000 000fffff 1 1
00095830533i[CPU0 ] |  MSR_FS_BASE:0000000000000000
00095830533i[CPU0 ] |  MSR_GS_BASE:0000000000000000
00095830533i[CPU0 ] | RIP=00000000c0003283 (00000000c0003283)
00095830533i[CPU0 ] | CR0=0xe0010011 CR1=0x0 CR2=0x00000000d00044d0
00095830533i[CPU0 ] | CR3=0x00003000 CR4=0x00000280
00095830533i[CPU0 ] >> mov dl, 0xd4 : B2D4
00095830533p[CPU0 ] >>PANIC<< exception(): 3rd (13) exception with no resolution

_________________
Rewriting virtual memory manager - Working on ELF support - Working on Device Drivers Handling

http://sourceforge.net/projects/jeko - Jeko Operating System


Top
 Profile  
 
 Post subject: Re: Really strange problem...
PostPosted: Thu Oct 23, 2008 7:29 pm 
Offline
Member
Member
User avatar

Joined: Fri Jun 27, 2008 8:05 pm
Posts: 162
Location: ND, USA
'Tis a page fault... check your paging code, and try mappin' all the physical address space to the kernel's virtual address space.

_________________
OS-LUX V0.0
Working on...
Memory management: the Pool


Last edited by cr2 on Fri Oct 24, 2008 6:08 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Really strange problem...
PostPosted: Thu Oct 23, 2008 8:38 pm 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

cr2 wrote:
'Tis a page fault... check your paging code, and try mappin' all the physical address space to the kernel's virtual address space.


Um - to me it looks like an IRQ, where the CPU is having problems when it tries to load the interrupt handler's CS and generates an (unhandled) general protection fault....


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: Really strange problem...
PostPosted: Fri Oct 24, 2008 2:19 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
I get the idea someone forgot to map the GDT...

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: Really strange problem...
PostPosted: Fri Oct 24, 2008 3:38 pm 
Offline
Member
Member
User avatar

Joined: Fri Mar 17, 2006 12:00 am
Posts: 500
Location: Napoli, Italy
Combuster wrote:
I get the idea someone forgot to map the GDT...


No, the GDT is mapped. In fact IRQs are issued, and some of them work without any error.

_________________
Rewriting virtual memory manager - Working on ELF support - Working on Device Drivers Handling

http://sourceforge.net/projects/jeko - Jeko Operating System


Top
 Profile  
 
 Post subject: Re: Really strange problem...
PostPosted: Fri Oct 24, 2008 3:58 pm 
Offline
Member
Member
User avatar

Joined: Sun Feb 18, 2007 7:28 pm
Posts: 1565
Is fdc->op modified by an external device or interrupt? I ask this because your while loop would be an infinity loop otherwise.

I would put a breakpoint right before that loop to see exactally what gets executed and when before the #GPF.

_________________
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}


Top
 Profile  
 
 Post subject: Re: Really strange problem...
PostPosted: Fri Oct 24, 2008 4:31 pm 
Offline
Member
Member
User avatar

Joined: Fri Mar 17, 2006 12:00 am
Posts: 500
Location: Napoli, Italy
neon wrote:
Is fdc->op modified by an external device or interrupt? I ask this because your while loop would be an infinity loop otherwise.

I would put a breakpoint right before that loop to see exactally what gets executed and when before the #GPF.


Yes, it's modified with an interrupt...
However now that code works, it's another thing after that doesn't work, but the error is similar as you see...

But I think the error isn't due to floppy driver, but to my kernel functions... Only that I don't know what can cause this error.

_________________
Rewriting virtual memory manager - Working on ELF support - Working on Device Drivers Handling

http://sourceforge.net/projects/jeko - Jeko Operating System


Top
 Profile  
 
 Post subject: Re: Really strange problem...
PostPosted: Fri Oct 24, 2008 5:09 pm 
Offline
Member
Member

Joined: Sun Jan 14, 2007 9:15 pm
Posts: 2566
Location: Sydney, Australia (I come from a land down under!)
Quote:
Code:
CR2=0x00000000d00044d0


PF followed by unavailable IDT meaning double fault, then GPF (hence triple fault and reboot)?

_________________
Pedigree | GitHub | Twitter | LinkedIn


Top
 Profile  
 
 Post subject: Re: Really strange problem...
PostPosted: Sat Oct 25, 2008 5:49 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 17, 2006 12:00 am
Posts: 500
Location: Napoli, Italy
pcmattman wrote:
Quote:
Code:
CR2=0x00000000d00044d0


PF followed by unavailable IDT meaning double fault, then GPF (hence triple fault and reboot)?


I have an IDT, it isn't unavailable. In fact, normally, exceptions and IRQs work fine. They work to a certain extent (infact the floppy's motor is started and stopped), and after there is that error.

_________________
Rewriting virtual memory manager - Working on ELF support - Working on Device Drivers Handling

http://sourceforge.net/projects/jeko - Jeko Operating System


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 34 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 7 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