flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > PCI devices check |
Author |
|
qandrew 02 Aug 2011, 14:17
BOTOKILLER wrote:
ESI = 1 in this code. Not 0. Try removing Code: inc esi |
|||
02 Aug 2011, 14:17 |
|
BOTOKILLER 02 Aug 2011, 14:28
qandrew wrote:
ESI = 1 ds:edi counter ds:edi+4 table starts address = [ds:edi+(esi*4)] esi=1 -> [ds:edi+(esi*4)] == ds:edi+4 Last edited by BOTOKILLER on 02 Aug 2011, 14:39; edited 1 time in total |
|||
02 Aug 2011, 14:28 |
|
qandrew 02 Aug 2011, 14:36
BOTOKILLER wrote: esi = 0 Then fix the comment in your code which says ESI is equal to 0. |
|||
02 Aug 2011, 14:36 |
|
BOTOKILLER 02 Aug 2011, 14:39
qandrew wrote:
yeah, missed that one Why that code returns empty buffer??? |
|||
02 Aug 2011, 14:39 |
|
BOTOKILLER 03 Aug 2011, 16:42
I debugged this code in virtual box - the only problem is that it always returns 0FFFFFFFFh in eax after PCI_READ call, but why???
|
|||
03 Aug 2011, 16:42 |
|
DJ Mauretto 03 Aug 2011, 18:12
Quote: I debugged this code in virtual box - the only problem is that it always returns 0FFFFFFFFh in eax after PCI_READ call, but why??? Because the address of bus device function is wrong, try again to rewrite the code, after learn the spec _________________ Nil Volentibus Arduum |
|||
03 Aug 2011, 18:12 |
|
BOTOKILLER 04 Aug 2011, 06:25
I calculated device like it is said on Osdev Wiki bits
bit 31 -must be set to make it work bits 16-23 - bus bits 15-11 - device bits 8-10 - function bits 2-7 - register |
|||
04 Aug 2011, 06:25 |
|
BOTOKILLER 04 Aug 2011, 06:26
DJ Mauretto wrote:
Also specs arent free)))) And its easier to seek knowledge from osdev) |
|||
04 Aug 2011, 06:26 |
|
DJ Mauretto 04 Aug 2011, 08:02
When you get FFFFFFFFH means that to the address there are no device..
I don't know Virtual box, anyway you first of all must check the presence of the controller, then start with Bus 0 Device 0 Function 0 Register 0 Now if you get FFFFFFFFH or 00000000H then there is no device at that address. Change Device with 1 ( max device = 31 ) and so on.. When you get the device you must checK Header Type to verify if the device is a Multifunction. If the Device is a Multifunction Device you must increment Function to 1 ( max function = 7) and check for other device Your algorithm is Bug.... plese make another attempt _________________ Nil Volentibus Arduum Last edited by DJ Mauretto on 05 Aug 2011, 06:18; edited 2 times in total |
|||
04 Aug 2011, 08:02 |
|
BOTOKILLER 04 Aug 2011, 11:38
DJ Mauretto wrote:
Yeah, maybe youre right I should rethink algorithm. When I wrote this piece of code i thought that if there isnt device № 10, then there isnt device № 11, it turned out not that simple))) |
|||
04 Aug 2011, 11:38 |
|
BOTOKILLER 04 Aug 2011, 16:59
Yeah, I made it - I didnt have to rewrite it comletely, I had to just wipe a few lines. The only thing I need now is how to get highest bus number to stop loop
Also I'll need to increase buffer to 2048d bytes, cuz I'm getting veeeeeeery long list Code: ;dont mind comments - they may not match improoved code ;_________________________________________________ FIND_DEVICES: ;[ds:edi] - buffer mov word [ds:edi], 0h xor esi, esi inc esi mov ecx, 0h ;preparing:[ds:edi]-counter, esi = 0(so, it doesnt overwrites counter), cx = 0 (ch = bus, cl = device & function) FD_LOOP: mov eax, ecx shl eax, 8d ;eax = address of device bts eax, 31d push eax call PCI_READ ;read pci config space with address in eax cmp ax, 0FFFFh ;if eax is not FFFFFFFFh jne NEXT_DEV ;save device address and class,else error pop eax ; jmp INCREM ;increment device and xor function RT_PT_: jmp FD_LOOP RETURN_FD: ret ;[ds:edi] - filled buffer INCREM: and cl, 11111000b add cx, 8h jmp RT_PT_ NEXT_DEV: pop eax mov [ds:edi+(esi*4)], eax inc esi mov al, 8h call PCI_READ mov [ds:edi+(esi*4)], eax inc word [ds:edi] inc esi inc cx jmp RT_PT_ ;______________________________________ |
|||
04 Aug 2011, 16:59 |
|
DJ Mauretto 04 Aug 2011, 17:05
Quote: Yeah, I made it - I didnt have to rewrite it comletely, I had to just wipe a few lines. The only thing I need now is how to get highest bus number to stop loop You have serious problem with yourself _________________ Nil Volentibus Arduum |
|||
04 Aug 2011, 17:05 |
|
BOTOKILLER 04 Aug 2011, 17:24
DJ Mauretto wrote:
I know P.S. I ve been mistaken about buffer - it looks so big just because function is relatively fast and isnt stopped - it just writes same values many times))) Last edited by BOTOKILLER on 04 Aug 2011, 17:36; edited 1 time in total |
|||
04 Aug 2011, 17:24 |
|
cod3b453 04 Aug 2011, 17:35
I believe if you scan the _MP_ tables this will tell you how many PCI busses there are (but I cannot confirm this). Another way is to simply probe them all or I think there is a "PCIR" table (which I have never tried).
Here's what I get on VirtualBox http://dl.dropbox.com/u/729869/os_vb.png (note this changes according to the controllers you enable) |
|||
04 Aug 2011, 17:35 |
|
BOTOKILLER 05 Aug 2011, 05:55
cod3b453 wrote: I believe if you scan the _MP_ tables this will tell you how many PCI busses there are (but I cannot confirm this). Another way is to simply probe them all or I think there is a "PCIR" table (which I have never tried). Yeah, I also get 9 devices As for number of busses - function is pretty fast so I better just check everything until 255 bus Code: cmp ch, 0FFh je RETURN_FD It works absolutely perfect! |
|||
05 Aug 2011, 05:55 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.