Subversion Repositories Kolibri OS

Rev

Rev 1993 | Blame | Last modification | View Log | Download | RSS feed

  1. ;***************************************************************
  2. ; project name:    PCI Device Enumeration
  3. ; target platform: KolibriOS
  4. ; compiler:        flat assembler 1.68
  5. ; version:         2.3
  6. ; last update:     Jule 2011
  7. ; maintained by:   Jason Delozier <cordata51@hotmail.com>
  8. ;                  Sergey Kuzmin <kuzmin_serg@list.ru>
  9. ;                  Mihailov Ilia <ghost.nsk@gmail.com>
  10. ;                  Marat Zakiyanov <mario79@bk.ru>
  11. ;                  Artem Jerdev  <art_zh@yahoo.com>
  12. ;                  Evgeny Grechnikov (diamond)
  13. ;                  Veronica (CleverMouse)
  14. ; old project site:  http://www.coolthemes.narod.ru/pcidev.html
  15. ; new project site:  http://board.kolibrios.org/viewtopic.php?f=42&t=73
  16. ;***************************************************************
  17. ;Summary: This program will attempt to scan the PCI Bus
  18. ;        and display basic information about each device
  19. ;        connected to the PCI Bus.
  20. ;***************************************************************
  21. ;-----------------------------------------------------------------------------
  22. include '../../../macros.inc'
  23.  
  24. include '../../../develop/libraries/box_lib/load_lib.mac'
  25. ;-----------------------------------------------------------------------------
  26.         use32
  27.         org 0x0
  28.         db 'MENUET01'   ; 8 byte id
  29.         dd 0x01         ; header version
  30.         dd START        ; start of code
  31.         dd IM_END       ; size of image
  32.         dd I_END        ; memory for app
  33.         dd stacktop     ; esp
  34.         dd 0    ; I_Param
  35.         dd path         ; APPLICATION PATH
  36. ;-----------------------------------------------------------------------------
  37. @use_library    ; load_lib macro
  38. ;-----------------------------------------------------------------------------
  39. START:
  40.         mcall   68,11
  41.         mcall   66,1,1
  42. ;-----------------------------------------------------------------------------
  43. load_libraries l_libs_start,end_l_libs
  44. ;-----------------------------------------------------------------------------
  45. ;OpenDialog     initialisation
  46.         push    dword OpenDialog_data
  47.         call    [OpenDialog_Init]
  48.        
  49.         mov     edi,filename_area
  50.         mov     esi,start_temp_file_name
  51.         call    copy_file_name_path
  52. ;-----------------------------------------------------------------------------
  53.         mcall   68,12,4096*4 ; 16 Kb - I hope this will be enough for store of data
  54.         mov     [store_text_area_start],eax
  55. ;----------------------------------------------------------------------------- 
  56.         call draw_window
  57. still:
  58.         mcall   10                      ; wait here for event
  59.         dec     eax                     ; redraw request ?
  60.         jz      red
  61.         dec     eax                     ; key in buffer ?
  62.         jz      key
  63.         dec     eax                     ; button in buffer ?
  64.         jz      button
  65.         jmp     still
  66. ;-----------------------------------------------------------------------------
  67. red:                                    ; redraw
  68.         mcall   9, Proc_Info, -1        ; window redraw requested so get new window coordinates and size
  69.         mov     eax, [Proc_Info.box.left]; store the window coordinates into the Form Structure
  70.         mov     [Form + 2], ax          ; x start position
  71.         mov     eax, [Proc_Info.box.top];
  72.         mov     [Form + 6], ax          ; ystart position
  73.         mov     eax, [Proc_Info.box.width]      ;
  74.         mov     [Form], ax              ; window width
  75.         mov     eax, [Proc_Info.box.height]     ;
  76.         mov     [Form + 4] ,ax          ; window height
  77.         call    draw_window             ; go redraw window now
  78.         jmp     still
  79. ;-----------------------------------------------------------------------------
  80. key:                                    ; key
  81.         mcall   2                       ; just read it and ignore
  82.         cmp     [extended_key],1
  83.         je      .extended_key
  84.         test    al, al
  85.         jnz     still
  86.         cmp     ah, 0xE0
  87.         jne     @f
  88.         mov     [extended_key],1
  89.         jmp     still
  90. @@:
  91.         cmp     ah,129  ; Esc
  92.         je      button.exit
  93.         cmp     ah,159
  94.         je      call_OpenDialog
  95.         jmp     still
  96. .extended_key:
  97.         mov     [extended_key],0
  98.         cmp     ah,129  ; Esc
  99.         je      button.exit
  100.         cmp     ah,159
  101.         je      call_OpenDialog
  102.         jmp     still
  103. ;-----------------------------------------------------------------------------
  104. button:                                 ; button
  105.         mcall   17                      ; get id
  106.         cmp     ah,2
  107.         je      call_OpenDialog
  108.         cmp     ah, 1                   ; button id = 1 ?
  109.         jne     still
  110. .exit:
  111.         mcall   -1                      ; close this program
  112. ;-----------------------------------------------------------------------------
  113. call_OpenDialog:
  114.         mov     [OpenDialog_data.type],1        ; Save
  115.        
  116.         push    dword OpenDialog_data
  117.         call    [OpenDialog_Start]
  118.  
  119.         cmp     [OpenDialog_data.status],2      ; OpenDialog does not start
  120.         je      .save_file_default_path
  121.        
  122.         cmp     [OpenDialog_data.status],1
  123.         jne     still
  124.        
  125.         call    store_data
  126.         jmp     still
  127. ;----------------------------------------      
  128. .save_file_default_path:
  129.         mov     edi,file_name
  130.         mov     esi,file_default_path
  131.         call    copy_file_name_path
  132.         call    store_data
  133.         jmp     still
  134. ;----------------------------------------      
  135. copy_file_name_path:
  136.         xor     eax,eax
  137.         cld
  138. @@:
  139.         lodsb
  140.         stosb
  141.         test    eax,eax
  142.         jnz     @r
  143.         ret
  144. ;-----------------------------------------------------------------------------
  145. prepare_text_area:
  146.         mov     edi,[store_text_area_start]
  147.  
  148.         push    edi
  149.         mov     ecx,4096 ; 16 Kb - I hope this will be enough for store of data
  150.         mov     eax,dword '    '
  151.         cld
  152.         rep     stosd
  153.         pop     edi
  154.        
  155.         mov     esi,PCIWin
  156.         xor     ecx,ecx
  157. @@:
  158.         mov     cl,[esi]
  159.         inc     esi
  160.         rep     movsb
  161.         mov     al,0Ah ; CR - carriage return
  162.         stosb
  163.         cmp     [esi],byte 0xFF
  164.         jne     @r     
  165.  
  166.         mov     [store_text_area_end],edi
  167.        
  168.         xor     edi,edi
  169.         ret
  170. ;----------------------------------------------------------------------------- 
  171. draw_window:
  172.         call    prepare_text_area
  173.        
  174.         mov     byte [total], 0
  175.         mcall   12, 1                   ; start of draw
  176.         ; DRAW WINDOW
  177.         mcall   0,dword [Form],dword [Form + 4],0x13ffffff,0x805080d0,title
  178.         mcall   8,<450,100>,<25,25>,2,0xC0C0C0
  179.         shr     ecx,16
  180.         mov     bx,cx
  181.         add     ebx,13 shl 16+4
  182.         mcall   4,,0x80000000,text_save_button
  183.         add     bx,11
  184.         mcall   ,,,text_save_button.1
  185.         ; Insert horizontal bars  in list area
  186.         mov     eax, 13                 ; draw bar system function
  187.         mov     ebx, 18                 ; set Xstart position of bar
  188.         shl     ebx, 16                 ;
  189.         mov     bx, word [Form] ; get width of window
  190.         sub     bx, 32                  ; bar is 32 pixels shorter then window width
  191.         mov     ecx, 119 * 65536 + 10   ; set Ystart(109) and Height(10) of bar   109
  192.         mov     edx, 0xC0C0C0           ; set color of bar
  193. again:  ;begin draw bar loop
  194.         mcall                           ; draw bar to window area
  195.         shr     ecx, 16                 ; move the Ystart position to working area
  196.         add     ecx, 34                 ; add 34 pixels to Y Start (moves bar down)
  197.         cmp     cx, word [Form + 4]     ; is the Ystart position outside of window area
  198.         jae     nomo                    ; if so stop drawing bars
  199.         sub     ecx, 14                 ; if not, we only need 20 pixels between bar tops
  200.         shl     ecx, 16                 ; set that values as Ystart
  201.         add     ecx, 10                 ; Bar Height is always 10 pixels
  202.         jmp     again                   ; draw another bar
  203. ;-----------------------------------------------------------------------------
  204. nomo:                                   ;done drawing bars here
  205.         ; start PCI stuff
  206.         call    Get_PCI_Info            ; get pci version and last bus, scan for and draw each pci device
  207.  
  208.         ; Window inteface
  209.         mov     cx, [PCI_Version]
  210.         add     ch, '0'
  211.         mov     [PCIWin + 85], ch       ; 0xBADCODE but it works !
  212.         mov     ch, cl
  213.         shr     cl, 4
  214.         and     ch, 0x0f
  215.         add     cx, '00'
  216.         mov     [PCIWin + 87], cx
  217.         mov     cl, [PCI_LastBus]       ; will only work if [PCI_LastBus] < 10
  218.         add     cl, '0'
  219.         mov     [PCIWin + 106], cl
  220.  
  221.         mov     edx, PCIWin
  222.         mov     ebx, 20 * 65536 + 25    ; x start, ystart of text
  223.         mov     ecx, 0x224466           ; color of text
  224.         mov     eax, 4
  225. @@:
  226.         movzx   esi, byte[edx]
  227.         inc     edx
  228.         mcall
  229.         add     ebx, 10
  230.         add     edx, esi
  231.         cmp     byte[edx], -1
  232.         jne     @b
  233.         ; Quantity of devices...
  234.         movzx   ecx, byte [total]       ; number to draw
  235.         mcall   47, 0x00020000,,150 * 65536 + 65, 0x224466
  236.        
  237.         mov     ebx,ecx
  238.         mov     ecx,2
  239.         mov     edi,[store_text_area_start]
  240.         add     edi,157
  241.         push    edi
  242.         call    binary_to_hex_string
  243.         pop     edi
  244.         mov     [edi+2],byte 'h'
  245.        
  246.         mov     ah, [MMIO_allowed]
  247.         or      ah, ah
  248.         jz      @f
  249.         mov     ah, [MMIO_Bus]  ; =255 if MMIO disabled / not found
  250.         and     ah, 0x7f
  251.         inc     ah
  252.         jo      @f     
  253.         call    Try_MMIO
  254. @@:
  255.         mcall   12, 2                   ; end of draw
  256.         ret
  257. ;-----------------------------------------------------------------------------
  258. store_data:
  259.         mov     eax,[store_text_area_start]
  260.         mov     [fileinfo.return],eax
  261.         mov     ebx,[store_text_area_end]
  262.         sub     ebx,eax
  263.         inc     ebx
  264.         mov     [fileinfo.size],ebx
  265.         mcall   70,fileinfo
  266.         ret
  267. ;-----------------------------------------------------------------------------
  268. ;* Gets the PCI Version and Last Bus
  269. Get_PCI_Info:
  270.         mcall   62, 0
  271.         mov     word [PCI_Version], ax
  272.         mcall   62, 1
  273.         mov     byte [PCI_LastBus], al
  274.         ;----------------------------------------------------------
  275.         ;* Get all devices on PCI Bus
  276.         cmp     al, 0xff                ; 0xFF means no pci bus found
  277.         jne     Pci_Exists              ;
  278.         ret                             ; if no bus then leave
  279. ;----------------------------------------------------------------------------- 
  280. Pci_Exists:
  281.         mov     byte [V_Bus], 0         ; reset varibles
  282.         mov     byte [V_Dev], 0         ;
  283.         mov     edx,  20 * 65536 + 110  ; set start write position
  284. Start_Enum:
  285.         mov     bl, 6                   ; get a dword
  286.         mov     bh, byte [V_Bus]        ; bus of pci device
  287.         mov     ch, byte [V_Dev]        ; device number/function
  288.         mov     cl, 0                   ; offset to device/vendor id
  289.         mcall   62                      ; get ID's
  290.  
  291.         cmp     ax, 0                   ; Vendor ID should not be 0 or 0xFFFF
  292.         je      nextDev                 ; check next device if nothing exists here
  293.        
  294.         cmp     ax, 0xffff              ;
  295.         je      nextDev                 ;
  296.  
  297.         mov     word [PCI_Vendor], ax   ; There is a device here, save the ID's
  298.         shr     eax, 16                 ;
  299.         mov     word [PCI_Device], ax   ;
  300.         mov     bl, 4                   ; Read config byte
  301.         mov     bh, byte [V_Bus]        ; Bus #
  302.         mov     ch, byte [V_Dev]        ; Device # on bus
  303.         mov     cl, 0x08                ; Register to read (Get Revision)
  304.         mcall   62                      ; Read it
  305.        
  306.         mov     byte [PCI_Rev], al      ; Save it
  307.         mov     cl, 0x0b                ; Register to read (Get class)
  308.         mcall   62                      ; Read it
  309.  
  310.         mov     byte [PCI_Class], al    ; Save it
  311.         mov     cl, 0x0a                ; Register to read (Get Subclass)
  312.         mcall   62                      ; Read it
  313.         mov     byte [PCI_SubClass], al; Save it
  314. ; by Mario79 august 2006
  315.         mov     cl, 0x09                ; Register to read (Get Interface)
  316.         mcall   62                      ; Read it
  317.        
  318.         mov  [PCI_Interface], al        ; Save it
  319. ;
  320. ; by Ghost april 2007
  321.         mov     cl, 0x3c                ; Register to read (Get IRQ)
  322. @@:
  323.         mcall   62                      ; Read it
  324.        
  325.         mov     [PCI_IRQ], al           ; Save it
  326. ; by CleverMouse juny 2011
  327.         mov     cl, 0x0e
  328.         mcall   62
  329.        
  330.         push    eax
  331.         inc     byte [total]            ; one more device found
  332.         call    Print_New_Device        ; print device info to screen
  333. ; don't scan for nonzero functions if zero function says "not multifunction device"
  334.         pop     eax
  335.         test    al, al
  336.         js      nextDev
  337.        
  338.         test    byte [V_Dev], 7
  339.         jnz     nextDev
  340.        
  341.         or      byte [V_Dev], 7
  342. nextDev:
  343.         inc     byte [V_Dev]            ; next device on this bus
  344.         jnz     Start_Enum              ; jump until we reach zero
  345.         ;(used to be JNO which caused bug!!! 30-4-2006, JMD)
  346.         mov     byte [V_Dev], 0         ; reset device number
  347.         inc     byte [V_Bus]            ; next bus
  348.         mov     al, byte [PCI_LastBus]  ; get last bus
  349.         cmp     byte [V_Bus], al        ; was it last bus
  350.         jbe     Start_Enum              ; if not jump to keep searching
  351.         ret
  352. ;-----------------------------------------------------------------------------
  353. no_ummio_allowed:
  354.         xor     al,al
  355.         mov     [MMIO_allowed],al               ; re-enter the subroutine
  356. ;------------------------------------------------------------------
  357. ;* Print device info to screen
  358.  
  359. Print_New_Device:
  360.         xor     esi, esi                ; default text color
  361.         mov     cl, [MMIO_allowed]
  362.         or      cl,cl
  363.         jz      no_ummio_here
  364.         mov     ch, byte [V_Bus]
  365.         mov     cl, byte [V_Dev]
  366.         mcall   62, 11          ; detect uMMIO
  367.        
  368.         and     ax,0x7fff
  369.         inc     ax                      ; -1 returned?
  370.         jo      no_ummio_allowed
  371.        
  372.         inc     ax                      ; -2 returned?
  373.         jo      no_ummio_here
  374.        
  375.         inc     ax                      ; -3 returned?
  376.         jo      no_ummio_here
  377.        
  378.         mov     esi, 0x990033   ; highlighted text color
  379.         mov     bh, byte [V_Bus]
  380.         mov     bl, byte [V_Dev]
  381.         mov     byte [MMIO_Bus], bh
  382.         mov     byte [MMIO_Dev], bl
  383.         add     bh,'0'
  384.         mov     [PCIWin + 129], bh      ; uMMIO bus
  385.         mov     al, bl
  386.         shr     al, 1
  387.         shr     al, 1
  388.         shr     al, 1
  389.         add     al,'0'
  390.         mov     [PCIWin + 131], al      ; uMMIO device
  391.         and     bl, 7
  392.         add     bl, '0'
  393.         mov     [PCIWin + 133], bl      ; uMMIO function
  394.  
  395. no_ummio_here:
  396.         movzx   ecx,word [PCI_Vendor]   ; Pointer to number to be written
  397.         mcall   47, 0x00040100          ; Write Vendor ID
  398.        
  399.         call    store_4_digits
  400.        
  401.         and     edx, 0xFFFF             ;*****************************************
  402.         or      edx, 54 * 65536 ; X start becomes 54
  403.         movzx   ecx, word [PCI_Device]  ; get Vendor ID
  404.         mcall                           ; Draw Vendor ID to Window
  405.  
  406.         call    store_4_digits
  407.        
  408.         and     edx, 0xFFFF             ;*****************************************
  409.         or      edx, 98 * 65536 ; X start becomes 98
  410.         movzx   ecx, byte [V_Bus]       ; get bus number
  411.         mcall   ,0x00020100             ; draw bus number to screen
  412.  
  413.         call    store_2_digits
  414.        
  415.         and     edx, 0xFFFF             ;*****************************************
  416.         or      edx, 128 * 65536        ; X start becomes 128
  417.         movzx   ecx, byte [V_Dev]       ; get device number
  418.         shr     ecx, 3                  ; device number is bits 3-7
  419.         mcall                           ; Draw device Number To Window
  420.  
  421.         call    store_2_digits
  422.        
  423.         and     edx, 0xFFFF             ;*****************************************
  424.         or      edx, 155 * 65536        ; X start becomes 155
  425.         movzx   ecx, byte [V_Dev]       ; get Function number
  426.         and     ecx, 7                  ; function is first 3 bits
  427.         mcall                           ; Draw Function Number To Window
  428.        
  429.         call    store_2_digits
  430.        
  431.         and     edx, 0xFFFF             ;*****************************************
  432.         or      edx, 179 * 65536        ; X start becomes 179
  433.         movzx   ecx, byte [PCI_Rev]     ; get revision number
  434.         mcall                           ; Draw Revision to screen
  435.        
  436.         call    store_2_digits
  437.        
  438.         and     edx, 0xFFFF             ;*****************************************
  439.         or      edx, 215*65536          ; X start becomes 215
  440.         movzx   ecx, byte [PCI_Class]   ; get PCI_Class
  441.         mcall                           ; Draw Class to screen
  442.        
  443.         call    store_2_digits
  444.        
  445.         and     edx, 0xFFFF             ;*****************************************
  446.         or      edx, 250*65536          ; X start becomes 250
  447.         movzx   ecx, byte [PCI_SubClass]; get sub class
  448.         mcall                           ; Draw Sub Class to screen
  449.        
  450.         call    store_2_digits
  451.        
  452. ; from Mario79 august 2006
  453.         and     edx, 0xFFFF             ;*****************************************
  454.         or      edx, 280 * 65536        ; X start becomes 280
  455.         movzx   ecx, [PCI_Interface]    ; get Interface
  456.         mcall
  457.        
  458.         call    store_2_digits
  459.        
  460. ;
  461. ; from Ghost april 2007                 ;*****************************************
  462.         and     edx, 0xFFFF
  463.         or      edx, 310 * 65536        ; X start becomes 310
  464.         movzx   ecx, [PCI_IRQ]          ; get Interface
  465.         cmp     cl, 0x0f                ; IRQ between 0..15
  466.         ja      @f
  467.  
  468.         mcall
  469.  
  470.         call    store_2_digits
  471.         jmp     .PCI_Vendor
  472. @@:    
  473.         call    store_NA
  474. .PCI_Vendor:
  475.         ;Write Names
  476.         movzx   ebx, dx         ; Set y position
  477.         or      ebx, 340 * 65536        ; set Xposition to 340
  478.  
  479. ;------------------------------------------------------------------
  480. ; Prints the Vendor's Name based on Vendor ID
  481. ;
  482. ; Modified on ??-04-2007 by Ghost for size
  483. ;------------------------------------------------------------------
  484.         mov     edx, VendorsTab
  485.         mov     cx, word[PCI_Vendor]
  486.  
  487. .fn:
  488.         mov     ax, [edx]
  489.         add     edx, 6
  490.         test    ax, ax
  491.         jz      .find
  492.        
  493.         cmp     ax, cx
  494.         jne     .fn
  495.        
  496. .find:
  497.         mov     edx, [edx - 4]
  498.         mcall   4,, 0x80000000          ; lets print the vendor Name
  499.        
  500.         mov     [store_text_size],42
  501.         call    store_text
  502. ;------------------------------------------------------------------
  503. ; Get description based on Class/Subclass
  504. ;
  505. ; Modified on ??-04-2007 by Ghost for size
  506. ;------------------------------------------------------------------
  507.         mov     eax, dword [PCI_Class]
  508.         and     eax, 0xffffff
  509.         xor     edx, edx
  510.         xor     esi, esi
  511. .fnc:
  512.         inc     esi
  513.         mov     ecx, [Classes + esi * 8 - 8]
  514.         cmp     cx, 0xffff
  515.         je      .endfc
  516.        
  517.         cmp     cx, ax
  518.         jne     .fnc
  519.        
  520.         test    ecx, 0xff000000
  521.         jz      @f
  522.        
  523.         mov     edx, [Classes + esi * 8 - 4]
  524.         jmp     .fnc
  525. @@:
  526.         cmp     eax, ecx
  527.         jne     .fnc
  528.        
  529.         xor     edx, edx
  530. .endfc:
  531.         test    edx, edx
  532.         jnz     @f
  533.        
  534.         mov     edx, [Classes + esi * 8 - 4]
  535. @@:
  536.         and     ebx, 0x0000FFFF         ; clear X position
  537.         or      ebx, 0x24E0000          ; set X position to 590 pixels
  538.         mcall   4,, 0x80000000,, 32     ; draw the text
  539.        
  540.         mov     [store_text_size],0
  541.         call    store_text
  542.         call    store_CR
  543.        
  544.         movzx   edx, bx         ; get y coordinate
  545.         add     edx, 0x0014000A         ; add 10 to y coordinate and set x coordinate to 20
  546.         mov     [gr_pos], edx
  547.         ret
  548. ;------------------------------------------------------------------
  549. ; Get the user-MMIO related info
  550. ;
  551. ; Added on ??-12-2009 by art_zh
  552. ;------------------------------------------------------------------
  553. Try_MMIO:
  554.         xor     ebx, ebx
  555.         mov     edx, ebx
  556.         mov     bh, [MMIO_BAR]
  557.         or      bx, 12                  ; function 12
  558.         mov     ecx, 4096               ; =1 page to map
  559.         mcall   62
  560.        
  561.         mov     [MMIO_Map], eax         ; store MMIO lin.addr.
  562.         mov     ecx, 0x80990022         ; print color : red
  563.         add     bh, '0'
  564.         cmp     eax, -3
  565.         jne     @f
  566.        
  567.         mov     [bar_um+3], bh
  568.         mov     ebx, [gr_pos]
  569.         mov     edx, bar_um
  570.         mcall   4
  571.        
  572.         jmp     mmio_next_bar
  573. @@:
  574.         cmp     eax, -4
  575.         jne     @f
  576.         mov     [bar_io+3], bh
  577.         mov     ebx, [gr_pos]
  578.         mov     edx, bar_io
  579.         mcall   4
  580.        
  581.         jmp     mmio_next_bar
  582. @@:
  583.         cmp     bh, '6'         ; expansion ROM ?
  584.         je      @f
  585.         mov     [bar_ram+3], bh
  586.         mov     ebx, [gr_pos]
  587.         mov     edx, bar_ram
  588.         mcall   4
  589.        
  590.         jmp     mmio_dump
  591. ;-----------------------------------------------------------------------------
  592. @@:
  593.         mov     ebx, [gr_pos]
  594.         mov     edx, bar_rom
  595.         mcall   4
  596.  
  597. mmio_dump:
  598.         mov     edx, [MMIO_Map]
  599.         mov     esi, 64
  600.         mov     ecx, 0x099              ; dump color : blue
  601.         add     ebx, 10
  602.         mov     [gr_pos], ebx
  603.         mcall   4
  604.        
  605.         mov     ecx, [MMIO_Map]         ; release the tried page
  606.         mcall   62,13
  607.  
  608. mmio_next_bar:
  609.         mov     bh, [MMIO_BAR]
  610.         inc     bh
  611.         cmp     bh,7
  612.         je      @f
  613.        
  614.         mov     [MMIO_BAR], bh
  615.         add     [gr_pos], 10
  616.         jmp     Try_MMIO
  617. ;-----------------------------------------------------------------------------
  618. @@:
  619.         xor     bh,bh
  620.         mov     [MMIO_BAR], bh
  621.         ret
  622. ;-----------------------------------------------------------------------------
  623. store_CR:
  624.         pusha
  625.         mov     edi,[store_text_area_end]
  626.         mov     [edi],word 0A20h ; CR (carriage return) + SPACE
  627.         add     dword [store_text_area_end],2
  628.         popa
  629.         ret    
  630. ;-----------------------------------------------------------------------------
  631. store_text:
  632.         pusha
  633.         inc     dword [store_text_area_end]
  634.         mov     esi,edx
  635.         mov     edi,[store_text_area_end]
  636.         push    edi
  637.         xor     eax,eax
  638.         cld
  639. @@:
  640.         lodsb
  641.         test    eax,eax
  642.         jz      @f
  643.         stosb
  644.         inc     dword [store_text_area_end]
  645.         jmp     @r
  646. @@:
  647.         pop     esi
  648.         mov     eax,[store_text_size]
  649.         test    eax,eax
  650.         jz      @f
  651.         sub     edi,esi
  652.         sub     eax,edi
  653.         add     [store_text_area_end],eax
  654. @@:
  655.         popa
  656.         ret    
  657. ;-----------------------------------------------------------------------------
  658. store_NA:
  659.         pusha
  660.         mov     ebx,edx
  661.         mcall   4,,0x80000000,text_NA
  662.         mov     edi,[store_text_area_end]
  663.         mov     ax,[edx]
  664.         mov     [edi+1],ax
  665.         add     [store_text_area_end],dword 5
  666.         popa
  667.         ret
  668. ;-----------------------------------------------------------------------------
  669. store_2_digits:
  670.         pusha
  671.         inc     [store_text_area_end]
  672.         mov     ebx,ecx
  673.         mov     ecx,2
  674.         mov     edi,[store_text_area_end]
  675.         call    binary_to_hex_string
  676.         add     [store_text_area_end],dword 4
  677.         popa
  678.         ret
  679. ;-----------------------------------------------------------------------------
  680. store_4_digits:
  681.         pusha
  682.         mov     ebx,ecx
  683.         mov     ecx,4
  684.         mov     edi,[store_text_area_end]
  685.         call    binary_to_hex_string
  686.         add     [store_text_area_end],dword 6
  687.         popa
  688.         ret
  689. ;-----------------------------------------------------------------------------
  690. ; ebx - value
  691. ; ecx - digits
  692. ; edi - output string
  693. binary_to_hex_string:
  694.         add     edi,ecx
  695.         dec     edi
  696.         std
  697. .1:
  698.         mov     al,bl
  699.         and     al,0xf
  700.         shr     ebx,4
  701.         cmp     al,9
  702.         jbe     @f
  703.  
  704.         add     al,0x27
  705. @@:
  706.         add     al,0x30
  707.         stosb
  708.         dec     ecx
  709.         jnz     .1
  710.         cld
  711.         ret
  712. ;-----------------------------------------------------------------------------
  713. include 'vendors.inc'
  714. ;-----------------------------------------------------------------------------
  715. ; DATA AREA
  716. DATA
  717.  
  718. Form:   dw 800 ; window width (no more, special for 800x600)
  719.         dw 100 ; window x start
  720.         dw 620 ; window height
  721.         dw 20 ; window y start
  722.  
  723. title   db 'PCI Device Enumerator v 2.3', 0
  724.  
  725. PCIWin mls \
  726.         '   Don`t forget to enable PCI Access to Applications in Setup Menu.',\
  727.         '',\
  728.         'PCI Version  = x.xx; Last PCI Bus = x',\
  729.         'User MMIO channel = 0F.F:F ',\
  730.         'Number of PCI units =    ',\
  731.         '',\
  732.         'VenID DevID Bus# Dev# Fnc Rev  Class  Subclass/ IRQ                 Company                      Description',\
  733.         '                                      Interface',\
  734.         '----- ----- ---- ---- --- ---  -----  --------- --- ------------------------------------------ --------------------------------'
  735.  
  736. bar_ram db 'BARx: MMIO block', 0
  737. bar_io  db 'BARx: IO ports',0
  738. bar_um  db 'BARx: unmapped',0
  739. bar_rom db 'BAR6: Expansion ROM', 0
  740.  
  741. text_save_button:
  742.         db 'Save PCI list',0
  743. .1:     db '(Press S key)',0
  744.  
  745. text_NA:
  746.         db '--',0
  747. ;---------------------------------------------------------------------
  748. system_dir_ProcLib      db '/sys/lib/proc_lib.obj',0
  749.  
  750. err_message_found_lib2  db 'proc_lib.obj - Not found!',0
  751.  
  752. err_message_import2     db 'proc_lib.obj - Wrong import!',0
  753.  
  754. head_f_i:
  755. head_f_l        db 'error',0
  756. ;---------------------------------------------------------------------
  757. l_libs_start:
  758.  
  759. library02  l_libs system_dir_ProcLib+9, path, library_path, system_dir_ProcLib, \
  760. err_message_found_lib2, head_f_l, ProcLib_import, err_message_import2, head_f_i
  761.  
  762. end_l_libs:
  763. ;---------------------------------------------------------------------
  764. align 4
  765. ProcLib_import:
  766. OpenDialog_Init         dd aOpenDialog_Init
  767. OpenDialog_Start        dd aOpenDialog_Start
  768. ;OpenDialog__Version    dd aOpenDialog_Version
  769.         dd      0
  770.         dd      0
  771. aOpenDialog_Init        db 'OpenDialog_init',0
  772. aOpenDialog_Start       db 'OpenDialog_start',0
  773. ;aOpenDialog_Version    db 'Version_OpenDialog',0
  774. ;---------------------------------------------------------------------
  775. align 4
  776. OpenDialog_data:
  777. .type                   dd 0
  778. .procinfo               dd Proc_Info    ;+4
  779. .com_area_name          dd communication_area_name      ;+8
  780. .com_area               dd 0    ;+12
  781. .opendir_pach           dd temp_dir_pach        ;+16
  782. .dir_default_pach       dd communication_area_default_pach      ;+20
  783. .start_path             dd open_dialog_path     ;+24
  784. .draw_window            dd draw_window  ;+28
  785. .status                 dd 0    ;+32
  786. .openfile_pach          dd file_name    ;+36
  787. .filename_area          dd filename_area        ;+40
  788. .filter_area            dd Filter
  789. .x:
  790. .x_size                 dw 420 ;+48 ; Window X size
  791. .x_start                dw 10 ;+50 ; Window X position
  792. .y:
  793. .y_size                 dw 320 ;+52 ; Window y size
  794. .y_start                dw 10 ;+54 ; Window Y position
  795.  
  796. communication_area_name:
  797.         db 'FFFFFFFF_open_dialog',0
  798. open_dialog_path:
  799.         db '/sys/File Managers/opendial',0
  800. communication_area_default_pach:
  801.         db '/sys',0
  802. Filter:
  803. dd      Filter.end - Filter.1
  804. .1:
  805. db      'TXT',0
  806. db      'LOG',0
  807. .end:
  808. dd      0
  809.  
  810. file_default_path:
  811.         db '/sys/'
  812. start_temp_file_name:  
  813.         db 'pcidev.txt',0
  814. ;---------------------------------------------------------------------
  815. align   4
  816. fileinfo:
  817. .subfunction    dd 2
  818. .Offset         dd 0
  819. .Offset_1       dd 0
  820. .size           dd 4096
  821. .return         dd 0
  822.                 db 0
  823. .name:          dd file_name
  824. ;-----------------------------------------------------------------------------
  825.  
  826. ; UNINITIALIZED DATA AREA
  827. IM_END:
  828. total           db ?
  829. V_Bus           db ?
  830. V_Dev           db ?
  831. PCI_Version     dw ?
  832. PCI_LastBus     db ?
  833. PCI_Device      dw ?
  834. PCI_Vendor      dw ?
  835. PCI_Bus         db ?
  836. PCI_Dev         db ?
  837. PCI_Rev         db ?
  838. ; don`t change order!!!
  839. PCI_Class       db ?
  840. PCI_SubClass    db ?
  841. PCI_Interface   db ?
  842. PCI_IRQ         db ?
  843.  
  844. align 4
  845. MMIO_Bus        db 255
  846. MMIO_Dev        db 255
  847. MMIO_BAR        db 0
  848. MMIO_allowed    db 1
  849. MMIO_Map        rd 8
  850.  
  851. gr_pos          dd ?
  852.  
  853. store_text_area_start   dd ?
  854. store_text_area_end     dd ?
  855. store_text_size         dd ?
  856.  
  857. extended_key    rb 1
  858. ;---------------------------------------------------------------------
  859. library_path:
  860.         rb 4096
  861. ;---------------------------------------------------------------------
  862. path:
  863.         rb 4096
  864. ;---------------------------------------------------------------------
  865. temp_dir_pach:
  866.         rb 4096
  867. ;---------------------------------------------------------------------
  868. file_name:
  869.         rb 4096
  870. ;---------------------------------------------------------------------
  871. file_name_1:
  872.         rb 4096
  873. ;---------------------------------------------------------------------
  874. filename_area:
  875.         rb 256
  876. ;---------------------------------------------------------------------
  877.         rb 4096
  878. stacktop:
  879. ;---------------------------------------------------------------------
  880. Proc_Info       process_information
  881. ;---------------------------------------------------------------------
  882. I_END:
  883. ;-----------------------------------------------------------------------------
  884.