Subversion Repositories Kolibri OS

Rev

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