Page 1 of 1

CD Driver Errors

Posted: Wed May 05, 2010 8:59 am
by bluechill
Before I say anything, I did not write this code, a person working with me on this OS did. He is from Germany so his english isn't so good. the words between the /* */ are his words, I did correct his spelling though.

/*
The picture should show the Class Id followed by the Device Id of all devices at the pci busses 0-256 and device number on each bus from 0-32.

The import part of the code is in the main file the for loop (l.151) and in the pci.cpp the pci_read_config_word (line 51) (the pciConfigReadWord in line 10. is from osdev but it shows the same result). May also important are the outl and inl methods above line 51.

Problem: It do not show any Mass_storage_control with the class code 0x01.

Maybe errors: The wrong offset.

*/

Also there is another weird error:

On a macbook pro 15" (running mac os x 10.6.3) this code triple faults both vmware fusion (Virtual CPU has enter a shutdown state) and qemu (See versions below)

On Midi Tower ATX 420W Netzteil, Front USB it does not crash qemu (See version below)

Qemu version for macbook pro:

QEMU PC emulator version 0.12.3, Copyright (c) 2003-2008 Fabrice Bellard

Qemu version for Midi Tower:

QEMU PC emulator version 0.12.3 (qemu-kvm-0.12.3), Copyright (c) 2003-2008 Fabrice Bellard

I believe that the problem may not be written properly considering that it crashes the macbook pro's version of qemu not the ubuntu 10.04.

Here is the url for the movie of the triple faulting in qemu and the project plus the screen shot of it "working" on ubuntu 10.04:

"Working" on ubuntu 10.04
FrostOS
Movie

Re: CD Driver Errors

Posted: Wed May 05, 2010 9:21 am
by Combuster
I would look for all those things that would cause segfaults in a hosted environment (out of bounds, stack smashes, uninitialized memory, ...)

Re: CD Driver Errors

Posted: Wed May 05, 2010 3:25 pm
by bluechill
Combuster wrote:I would look for all those things that would cause segfaults in a hosted environment (out of bounds, stack smashes, uninitialized memory, ...)
well one thing I forgot to mention was that if I remove from main.cpp at the very start, cout.clear();, line 34, it gives me the following:

Code: Select all

qemu: fatal: Trying to execute code outside RAM or ROM at 0xe8000f53

EAX=52eb5a00 EBX=00107004 ECX=0010bad8 EDX=0010bb2c
ESI=07f82b16 EDI=000fffff EBP=066850c0 ESP=000f39d0
EIP=e8000f53 EFL=00200002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
CS =0008 00000000 ffffffff 00cf9a00 DPL=0 CS32 [-R-]
SS =0010 00000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
DS =0010 00000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
FS =0010 00000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
GS =0010 00000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT=     00008340 00000027
IDT=     00000000 000003ff
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000 
DR6=ffff0ff0 DR7=00000400
CCS=00000008 CCD=52eb5a00 CCO=LOGICB  
FCW=037f FSW=0000 [ST=0] FTW=00 MXCSR=00001f80
FPR0=0000000000000000 FPR1=0000000000000000
FPR2=0000000000000000 FPR3=0000000000000000
FPR4=0000000000000000 FPR5=0000000000000000
FPR6=0000000000000000 FPR7=0000000000000000
XMM00=00000000000000000000000000000000 XMM01=00000000000000000000000000000000
XMM02=00000000000000000000000000000000 XMM03=00000000000000000000000000000000
XMM04=00000000000000000000000000000000 XMM05=00000000000000000000000000000000
XMM06=00000000000000000000000000000000 XMM07=00000000000000000000000000000000
except, I don't know why it is even accessing that, also this still only happens on my version of qemu (mac os x), plus my friend didn't know why it was accessing that address, I can only assume it is something with the pci because my other version (the version which works) doesn't do this when I remove that code.

I wonder if that is something, but right now I'm going to go check to see if something like what you said is happening.

Re: CD Driver Errors

Posted: Sun May 09, 2010 12:26 pm
by bluechill
well after debugging we found nothing. Then I just changed PCI start to PCI *start; and then changed the . to -> and it works fine now.


Can I have some help with why this happens? I'm totally confused

Re: CD Driver Errors

Posted: Sun May 09, 2010 12:48 pm
by Selenic
bluechill wrote:well after debugging we found nothing. Then I just changed PCI start to PCI *start; and then changed the . to -> and it works fine now.
This *should* be something you can work out on your own, as it's one of the more integral features of C. I can't give you anything more specific than that anyway without looking at your code.
Most likely you're passing it as an argument to a function; using a pointer causes modifications made in the callee to affect the caller's version, while using the value doesn't.

Re: CD Driver Errors

Posted: Sun May 09, 2010 3:15 pm
by pcmattman
Note: assuming you're writing C++ here from the two minor hints you've dropped. If you want real answers, try giving some real information about your code.

If removing cout.clear() changes behaviour significantly, you probably aren't calling global/static constructors properly when you start the kernel. There's code examples of that on the wiki - see C++.
well after debugging we found nothing. Then I just changed PCI start to PCI *start; and then changed the . to -> and it works fine now.
If that was a parameter to a function, you may be missing memcpy. GCC will use memcpy to move parameters to functions after a certain size threshold.

Re: CD Driver Errors

Posted: Sun May 09, 2010 5:23 pm
by bluechill
pcmattman wrote:Note: assuming you're writing C++ here from the two minor hints you've dropped. If you want real answers, try giving some real information about your code.

If removing cout.clear() changes behaviour significantly, you probably aren't calling global/static constructors properly when you start the kernel. There's code examples of that on the wiki - see C++.
well after debugging we found nothing. Then I just changed PCI start to PCI *start; and then changed the . to -> and it works fine now.
If that was a parameter to a function, you may be missing memcpy. GCC will use memcpy to move parameters to functions after a certain size threshold.
I'm assuming something like this:

Code: Select all

extern void memcpy(void *_d, void *_s, unsigned short n);
? because I have that.

Also I am using the icxxabi header and cpp file found on the wiki. I plan to change it around a little once I have this and memory management working.

Also here is some real info about my code:

It is written in C++, it contains a partially working CD Driver, it does not have full-blown memory management, it only contains paging. The code were working on, the CD Driver, uses the PCI for BAR4s and such, see IDE on the wiki.