flat assembler
Message board for the users of flat assembler.

Index > MenuetOS > partition 2 and pci scan

Author
Thread Post new topic Reply to topic
muitnep



Joined: 20 Jan 2010
Posts: 3
muitnep
Hello,

I downloaded m32-085.img and found a bug in fat32.asm, at line 173,
guess it should be :

Code:
  hdapl1:

    add   ebx,16

    mov eax, [ebx}    ; old : add   eax,[ebx]

    loop  hdapl1
    


so, now i can access my second partition from menuet
and wrote a program like its described in pci.txt at :

How to scan system for PCI devices

but it finds pci devices for every bus at every devfn,
how can i do this correctly, whats the problem?
anybody done this before? any ideas ? (yes, pci support for apps is enabled)

Code:
    
mov eax,62
int 0x40
mov [lbus],al   ; lbus is the last bus 

  mov dl,0
  loop3:
   mov ch,0
   loop4:
    mov bl,6
    mov bh,dl
    ;ch=devfn
    mov cl,0
    mov eax,63
    int 0x40
    cmp ax,0
    je next
    cmp ax,0xffff
    je next
     mov edx,alertText  
     call println ; I get alot of output and if i turn the je operations into 
                      ;  jne operations i got none, so it looks like there is a device in every place. or?
    next:

   add ch,1
   cmp ch,255
   jne loop4

  add dl,1
  cmp dl,[lbus]
  jne loop3    



Thanks very much.
Post 20 Jan 2010, 20:30
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
muitnep, I didn't look at that source but are you sure your code is a proper fix? If MOV is the real fix then the code could be just this:
Code:
  hdapl1:

    add ecx, ecx ; add   ebx,16

    mov eax, [ebx+ecx*8] ; mov eax, [ebx}    ; old : add   eax,[ebx]

    xor ecx, ecx ; <- If really needed; loop  hdapl1    

Well, it is almost equivalent, LOOP here would have iterated 2^32 times when ECX is zero but I believe some code above was guarding against that possibility or it is impossible to have ECX=0 in the first place.
Post 20 Jan 2010, 21:27
View user's profile Send private message Reply with quote
muitnep



Joined: 20 Jan 2010
Posts: 3
muitnep
OK... a proper fix? maybe.. (it works now and didnt before,so yes? could be better code,thats true..
here some more code :
Code:
....
mov ecx,[fat32part]

mov eax,0

mov,ebx,buffer+0x1be + 8 - 16 ; in buffer is the MBR and every partion is descrbed with 16 byte

hdapl1: 

add ebx,16

mov eax,[ebx]

loop hdapl1

mov [PARTION_START],eax
....
    

so ecx is 0 if you use your first partion,
and i am not sure what you say abbout the 2^32 iteration thing...

anyway, i will have a look at ethernet.inc to see how pci scanning works.
found out that my SIS900 card (linux says (rev. 6Cool) works very fine, (YEAH)
Post 21 Jan 2010, 10:34
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
AMD's description of LOOP wrote:
Decrements the count register (rCX) by 1, then, if rCX is not 0 and the ZF flag meets
the condition specified by the mnemonic, it jumps to the target instruction specified
by the signed 8-bit relative offset. Otherwise, it continues with the next instruction
after the LOOPcc instruction.


For that reason, if ECX is zero then the code will iterate 2^32, i.e. 4294967296 times. If no page-fault/GP-fault occurs in the middle you'll actually get partition 0 due to the modular arithmetic thing but after some seconds due to the very long iteration count.

If partitions are really zero-based you should use my code and if not then use "mov eax, [ebx+ecx*8-16]"

After looking here I see this:
Quote:
08h DWORD sectors preceding partition


If that field counts from the beginning of the disk rather than from the previous partition then OK, you have to use MOV and you can remove the LOOP because it is useless, otherwise the ADD is required or the calculation is just not that simple.

The code can be this:
Code:
mov ecx, [fat32part] ; I'll assume 1..4 range as it is typical to start from 1 on this.

hdapl1: ; <- Not really required
add ecx, ecx ; Pre-multiply by 2 since addresses index can't be scaled by 16
mov eax, dword [ebx + buffer + 0x1be + ecx*8 - 16 + 8] ; fasm will compile something of the form mov eax, [ebx+ecx*8+number] here
mov [PARTITION_START], eax    
Post 21 Jan 2010, 16:42
View user's profile Send private message Reply with quote
muitnep



Joined: 20 Jan 2010
Posts: 3
muitnep
ah, i see... partion count goes from 1 to 4, sorry.
but in my case "that field" counts from the beginning of the disk but not sure if its always like this... and or if its usefull to try both ?(think so) my disk is formated this year with some kind of debian install cd...

by the way, anybody knows where to find ac97player sources for 32bitMos?
Post 22 Jan 2010, 07:27
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.