OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 1:45 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: PCI Scan Shows no storage controllers
PostPosted: Thu Apr 13, 2023 8:17 am 
Offline

Joined: Thu Apr 13, 2023 7:51 am
Posts: 9
Hi, I am having an issue where i do a pci scan(brute force). But i don't seem to find any storage devices/controllers.
When i use command -> lspci -vv <- in the linux "konsole".
From reading the devices that it has recognised, it shows that it detected a SATA controller on a
ISA bridge on function 2 of bus 0 device 0x1F.

But when i read the ISA bridge header common variables on function 0. The header type is 0x8D and from what i
have read in the PCI link on the Main Page there should be 3 types(0x80/0x81/0x82). Also when i read function 2
the common variables are all 0.

I have tested on both qemu and my own hardware and shows no storage controllers(class 0x01) even though i ignore the subclass.

So i am unsure how Linux detected this.
Any advice on how i should move forward would be appreciated.


Top
 Profile  
 
 Post subject: Re: PCI Scan Shows no storage controllers
PostPosted: Thu Apr 13, 2023 5:37 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
It sounds like your code to read the PCI configuration space doesn't work properly. The header type is not 0x8D, and function 2 should have nonzero values in its configuration space.


Top
 Profile  
 
 Post subject: Re: PCI Scan Shows no storage controllers
PostPosted: Fri Apr 14, 2023 7:30 am 
Offline

Joined: Thu Apr 13, 2023 7:51 am
Posts: 9
Hi Octocontrabass, you were right i had some bugs in my code when bit shifting the function number into the register before using the out command and it resulted in reading function 0 with a masked offset:

faulty code:

; ecx is the device count --- ebx is the bus count --- edi is the offset --- edx is the function number
_PCIRead: xor eax,eax

or edi,0x80000000
and edi,0x800000FC
or al,bl
shl eax,8
shl ecx,3
or al,cl
shr ecx,3
shl eax,5
or al,dl ; this line is supposed to exchange positions with the line above it and then i can merge the two shl commands to shl eax,8
shl eax,3
or eax,edi
mov dx,0xCF8
out dx,eax
mov dx,0xCFC
in eax,dx
ret

I should have tested more thoroughly, I'm sorry.
This is my first topic. Do i close the topic or do the moderators?


Top
 Profile  
 
 Post subject: Re: PCI Scan Shows no storage controllers
PostPosted: Fri Apr 14, 2023 10:25 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
There's no need to close the topic.

Is there any particular reason why you chose to write this function in assembly? It's much easier to catch mistakes in higher-level languages.


Top
 Profile  
 
 Post subject: Re: PCI Scan Shows no storage controllers
PostPosted: Fri Apr 14, 2023 12:27 pm 
Offline

Joined: Thu Apr 13, 2023 7:51 am
Posts: 9
Even though this is my first time working through OS development, i am trying to do the whole thing(my software idea not a full OS) in assembly. I did try to look at how i could use c but was not sure how to set the origin point of the code as you can do in an assembler like nasm([org 0x7C00]). I am more interested in assembly anyway so i just gave up on c. Its a little crazy to do it in assembly but i am enjoying it so far.


Top
 Profile  
 
 Post subject: Re: PCI Scan Shows no storage controllers
PostPosted: Fri Apr 14, 2023 12:57 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
Z3NT0N wrote:
I did try to look at how i could use c but was not sure how to set the origin point of the code as you can do in an assembler like nasm([org 0x7C00]).

You can do that using a linker script. You probably wouldn't want to write a boot sector in C, though.


Top
 Profile  
 
 Post subject: Re: PCI Scan Shows no storage controllers
PostPosted: Fri Apr 14, 2023 1:22 pm 
Offline

Joined: Thu Apr 13, 2023 7:51 am
Posts: 9
The way i have been doing it so far is that I have been writing the code in "kate" on linux haha and then i assemble each file ("nasm -f bin name.asm -o name.img"), I have one file for the bootloader, one for the protected mode switch and then a third for my main code that runs after the PE switch. I then combine the binary outputs and then boot from that, its quite messy but seems to be working. Thank you for the link, I will have a look.


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: Bing [Bot], Google [Bot] and 73 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