Subversion Repositories Kolibri OS

Rev

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