Subversion Repositories Kolibri OS

Rev

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