Subversion Repositories Kolibri OS

Rev

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