Subversion Repositories Kolibri OS

Rev

Rev 7900 | Go to most recent revision | 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.  
  254.         mov     ebx,ecx
  255.         mov     ecx,2
  256.         mov     edi,[store_text_area_start]
  257.         add     edi,157
  258.         push    edi
  259.         call    binary_to_hex_string
  260.         pop     edi
  261.         mov     [edi+2],byte 'h'
  262.  
  263.         mov     ah, [MMIO_allowed]
  264.         or      ah, ah
  265.         jz      @f
  266.         mov     ah, [MMIO_Bus]  ; =255 if MMIO disabled / not found
  267.         and     ah, 0x7f
  268.         inc     ah
  269.         jo      @f
  270.         call    Try_MMIO
  271. @@:
  272. .end:
  273.         mcall   SF_REDRAW, SSF_END_DRAW
  274.         ret
  275. ;-----------------------------------------------------------------------------
  276. store_data:
  277.         mov     eax,[store_text_area_start]
  278.         mov     [fileinfo.return],eax
  279.         mov     ebx,[store_text_area_end]
  280.         sub     ebx,eax
  281.         inc     ebx
  282.         mov     [fileinfo.size],ebx
  283.         mcall   SF_FILE,fileinfo
  284.         ret
  285. ;-----------------------------------------------------------------------------
  286. ;* Gets the PCI Version and Last Bus
  287. Get_PCI_Info:
  288.         mcall   SF_PCI, 0
  289.         mov     word [PCI_Version], ax
  290.         mcall   SF_PCI, 1
  291.         mov     byte [PCI_LastBus], al
  292.         ;----------------------------------------------------------
  293.         ;* Get all devices on PCI Bus
  294.         cmp     al, 0xff                ; 0xFF means no pci bus found
  295.         jne     Pci_Exists              ;
  296.         ret                             ; if no bus then leave
  297. ;-----------------------------------------------------------------------------
  298. Pci_Exists:
  299.         mov     byte [V_Bus], 0         ; reset varibles
  300.         mov     byte [V_Dev], 0         ;
  301.         mov     edx,  20 * 65536 + 110  ; set start write position
  302. Start_Enum:
  303.         mov     bl, 6                   ; get a dword
  304.         mov     bh, byte [V_Bus]        ; bus of pci device
  305.         mov     ch, byte [V_Dev]        ; device number/function
  306.         mov     cl, 0                   ; offset to device/vendor id
  307.         mcall   SF_PCI                  ; get ID's
  308.  
  309.         cmp     ax, 0                   ; Vendor ID should not be 0 or 0xFFFF
  310.         je      nextDev                 ; check next device if nothing exists here
  311.  
  312.         cmp     ax, 0xffff              ;
  313.         je      nextDev                 ;
  314.  
  315.         mov     word [PCI_Vendor], ax   ; There is a device here, save the ID's
  316.         shr     eax, 16                 ;
  317.         mov     word [PCI_Device], ax   ;
  318.         mov     bl, 4                   ; Read config byte
  319.         mov     bh, byte [V_Bus]        ; Bus #
  320.         mov     ch, byte [V_Dev]        ; Device # on bus
  321.         mov     cl, 0x08                ; Register to read (Get Revision)
  322.         mcall   SF_PCI                  ; Read it
  323.  
  324.         mov     byte [PCI_Rev], al      ; Save it
  325.         mov     cl, 0x0b                ; Register to read (Get class)
  326.         mcall   SF_PCI                  ; Read it
  327.  
  328.         mov     byte [PCI_Class], al    ; Save it
  329.         mov     cl, 0x0a                ; Register to read (Get Subclass)
  330.         mcall   SF_PCI                  ; Read it
  331.         mov     byte [PCI_SubClass], al; Save it
  332. ; by Mario79 august 2006
  333.         mov     cl, 0x09                ; Register to read (Get Interface)
  334.         mcall   SF_PCI                  ; Read it
  335.  
  336.         mov  [PCI_Interface], al        ; Save it
  337. ;
  338. ; by Ghost april 2007
  339.         mov     cl, 0x3c                ; Register to read (Get IRQ)
  340. @@:
  341.         mcall   SF_PCI                  ; Read it
  342.  
  343.         mov     [PCI_IRQ], al           ; Save it
  344. ; by CleverMouse juny 2011
  345.         mov     cl, 0x0e
  346.         mcall   SF_PCI
  347.  
  348.         push    eax
  349.         inc     byte [total]            ; one more device found
  350.         call    Print_New_Device        ; print device info to screen
  351. ; don't scan for nonzero functions if zero function says "not multifunction device"
  352.         pop     eax
  353.         test    al, al
  354.         js      nextDev
  355.  
  356.         test    byte [V_Dev], 7
  357.         jnz     nextDev
  358.  
  359.         or      byte [V_Dev], 7
  360. nextDev:
  361.         inc     byte [V_Dev]            ; next device on this bus
  362.         jnz     Start_Enum              ; jump until we reach zero
  363.         ;(used to be JNO which caused bug!!! 30-4-2006, JMD)
  364.         mov     byte [V_Dev], 0         ; reset device number
  365.         inc     byte [V_Bus]            ; next bus
  366.         mov     al, byte [PCI_LastBus]  ; get last bus
  367.         cmp     byte [V_Bus], al        ; was it last bus
  368.         jbe     Start_Enum              ; if not jump to keep searching
  369.         ret
  370. ;-----------------------------------------------------------------------------
  371. no_ummio_allowed:
  372.         xor     al,al
  373.         mov     [MMIO_allowed],al               ; re-enter the subroutine
  374. ;------------------------------------------------------------------
  375. ;* Print device info to screen
  376.  
  377. Print_New_Device:
  378.         xor     esi, esi                ; default text color
  379.         mov     cl, [MMIO_allowed]
  380.         or      cl,cl
  381.         jz      no_ummio_here
  382.         mov     ch, byte [V_Bus]
  383.         mov     cl, byte [V_Dev]
  384.         mcall   SF_PCI, 11              ; detect uMMIO
  385.  
  386.         and     ax,0x7fff
  387.         inc     ax                      ; -1 returned?
  388.         jo      no_ummio_allowed
  389.  
  390.         inc     ax                      ; -2 returned?
  391.         jo      no_ummio_here
  392.  
  393.         inc     ax                      ; -3 returned?
  394.         jo      no_ummio_here
  395.  
  396.         mov     esi, 0x990033   ; highlighted text color
  397.         mov     bh, byte [V_Bus]
  398.         mov     bl, byte [V_Dev]
  399.         mov     byte [MMIO_Bus], bh
  400.         mov     byte [MMIO_Dev], bl
  401.         add     bh,'0'
  402.         mov     [PCIWin + 129], bh      ; uMMIO bus
  403.         mov     al, bl
  404.         shr     al, 1
  405.         shr     al, 1
  406.         shr     al, 1
  407.         add     al,'0'
  408.         mov     [PCIWin + 131], al      ; uMMIO device
  409.         and     bl, 7
  410.         add     bl, '0'
  411.         mov     [PCIWin + 133], bl      ; uMMIO function
  412.  
  413. no_ummio_here:
  414.         movzx   ecx,word [PCI_Vendor]   ; Pointer to number to be written
  415.         mcall   SF_DRAW_NUMBER, 0x00040100              ; Write Vendor ID
  416.  
  417.         call    store_4_digits
  418.  
  419.         and     edx, 0xFFFF             ;*****************************************
  420.         or      edx, 54 * 65536 ; X start becomes 54
  421.         movzx   ecx, word [PCI_Device]  ; get Vendor ID
  422.         mcall                           ; Draw Vendor ID to Window
  423.  
  424.         call    store_4_digits
  425.  
  426.         and     edx, 0xFFFF             ;*****************************************
  427.         or      edx, 98 * 65536 ; X start becomes 98
  428.         movzx   ecx, byte [V_Bus]       ; get bus number
  429.         mcall   ,0x00020100             ; draw bus number to screen
  430.  
  431.         call    store_2_digits
  432.  
  433.         and     edx, 0xFFFF             ;*****************************************
  434.         or      edx, 128 * 65536        ; X start becomes 128
  435.         movzx   ecx, byte [V_Dev]       ; get device number
  436.         shr     ecx, 3                  ; device number is bits 3-7
  437.         mcall                           ; Draw device Number To Window
  438.  
  439.         call    store_2_digits
  440.  
  441.         and     edx, 0xFFFF             ;*****************************************
  442.         or      edx, 155 * 65536        ; X start becomes 155
  443.         movzx   ecx, byte [V_Dev]       ; get Function number
  444.         and     ecx, 7                  ; function is first 3 bits
  445.         mcall                           ; Draw Function Number To Window
  446.  
  447.         call    store_2_digits
  448.  
  449.         and     edx, 0xFFFF             ;*****************************************
  450.         or      edx, 179 * 65536        ; X start becomes 179
  451.         movzx   ecx, byte [PCI_Rev]     ; get revision number
  452.         mcall                           ; Draw Revision to screen
  453.  
  454.         call    store_2_digits
  455.  
  456.         and     edx, 0xFFFF             ;*****************************************
  457.         or      edx, 215*65536          ; X start becomes 215
  458.         movzx   ecx, byte [PCI_Class]   ; get PCI_Class
  459.         mcall                           ; Draw Class to screen
  460.  
  461.         call    store_2_digits
  462.  
  463.         and     edx, 0xFFFF             ;*****************************************
  464.         or      edx, 250*65536          ; X start becomes 250
  465.         movzx   ecx, byte [PCI_SubClass]; get sub class
  466.         mcall                           ; Draw Sub Class to screen
  467.  
  468.         call    store_2_digits
  469.  
  470. ; from Mario79 august 2006
  471.         and     edx, 0xFFFF             ;*****************************************
  472.         or      edx, 280 * 65536        ; X start becomes 280
  473.         movzx   ecx, [PCI_Interface]    ; get Interface
  474.         mcall
  475.  
  476.         call    store_2_digits
  477.  
  478. ;
  479. ; from Ghost april 2007                 ;*****************************************
  480.         and     edx, 0xFFFF
  481.         or      edx, 310 * 65536        ; X start becomes 310
  482.         movzx   ecx, [PCI_IRQ]          ; get Interface
  483.         cmp     cl, 63                  ; IRQ between 0..63
  484.         ja      @f
  485.  
  486.         mcall
  487.  
  488.         call    store_2_digits
  489.         jmp     .PCI_Vendor
  490. @@:
  491.         call    store_NA
  492. .PCI_Vendor:
  493.         ;Write Names
  494.         movzx   ebx, dx         ; Set y position
  495.         or      ebx, 340 * 65536        ; set Xposition to 340
  496.  
  497. ;------------------------------------------------------------------
  498. ; Prints the Vendor's Name based on Vendor ID
  499. ;
  500. ; Modified on ??-04-2007 by Ghost for size
  501. ;------------------------------------------------------------------
  502.         mov     edx, VendorsTab
  503.         mov     cx, word[PCI_Vendor]
  504.  
  505. .fn:
  506.         mov     ax, [edx]
  507.         add     edx, 6
  508.         test    ax, ax
  509.         jz      .find
  510.  
  511.         cmp     ax, cx
  512.         jne     .fn
  513.  
  514. .find:
  515.         mov     edx, [edx - 4]
  516.         mcall   SF_DRAW_TEXT,, 0x80000000               ; lets print the vendor Name
  517.  
  518.         mov     [store_text_size],42
  519.         call    store_text
  520. ;------------------------------------------------------------------
  521. ; Get description based on Class/Subclass
  522. ;
  523. ; Modified on ??-04-2007 by Ghost for size
  524. ;------------------------------------------------------------------
  525.         mov     eax, dword [PCI_Class]
  526.         and     eax, 0xffffff
  527.         xor     edx, edx
  528.         xor     esi, esi
  529. .fnc:
  530.         inc     esi
  531.         mov     ecx, [Classes + esi * 8 - 8]
  532.         cmp     cx, 0xffff
  533.         je      .endfc
  534.  
  535.         cmp     cx, ax
  536.         jne     .fnc
  537.  
  538.         test    ecx, 0xff000000
  539.         jz      @f
  540.  
  541.         mov     edx, [Classes + esi * 8 - 4]
  542.         jmp     .fnc
  543. @@:
  544.         cmp     eax, ecx
  545.         jne     .fnc
  546.  
  547.         xor     edx, edx
  548. .endfc:
  549.         test    edx, edx
  550.         jnz     @f
  551.  
  552.         mov     edx, [Classes + esi * 8 - 4]
  553. @@:
  554.         and     ebx, 0x0000FFFF         ; clear X position
  555.         or      ebx, 0x24E0000          ; set X position to 590 pixels
  556.         mcall   SF_DRAW_TEXT,, 0x80000000,, 32  ; draw the text
  557.  
  558.         mov     [store_text_size],0
  559.         call    store_text
  560.         call    store_CR
  561.  
  562.         movzx   edx, bx         ; get y coordinate
  563.         add     edx, 0x0014000A         ; add 10 to y coordinate and set x coordinate to 20
  564.         mov     [gr_pos], edx
  565.         ret
  566. ;------------------------------------------------------------------
  567. ; Get the user-MMIO related info
  568. ;
  569. ; Added on ??-12-2009 by art_zh
  570. ;------------------------------------------------------------------
  571. Try_MMIO:
  572.         xor     ebx, ebx
  573.         mov     edx, ebx
  574.         mov     bh, [MMIO_BAR]
  575.         or      bx, 12                  ; function 12
  576.         mov     ecx, 4096               ; =1 page to map
  577.         mcall   SF_PCI
  578.  
  579.         mov     [MMIO_Map], eax         ; store MMIO lin.addr.
  580.         mov     ecx, 0x80990022         ; print color : red
  581.         add     bh, '0'
  582.         cmp     eax, -3
  583.         jne     @f
  584.  
  585.         mov     [bar_um+3], bh
  586.         mov     ebx, [gr_pos]
  587.         mov     edx, bar_um
  588.         mcall   SF_DRAW_TEXT
  589.  
  590.         jmp     mmio_next_bar
  591. @@:
  592.         cmp     eax, -4
  593.         jne     @f
  594.         mov     [bar_io+3], bh
  595.         mov     ebx, [gr_pos]
  596.         mov     edx, bar_io
  597.         mcall   SF_DRAW_TEXT
  598.  
  599.         jmp     mmio_next_bar
  600. @@:
  601.         cmp     bh, '6'         ; expansion ROM ?
  602.         je      @f
  603.         mov     [bar_ram+3], bh
  604.         mov     ebx, [gr_pos]
  605.         mov     edx, bar_ram
  606.         mcall   SF_DRAW_TEXT
  607.  
  608.         jmp     mmio_dump
  609. ;-----------------------------------------------------------------------------
  610. @@:
  611.         mov     ebx, [gr_pos]
  612.         mov     edx, bar_rom
  613.         mcall   SF_DRAW_TEXT
  614.  
  615. mmio_dump:
  616.         mov     edx, [MMIO_Map]
  617.         mov     esi, 64
  618.         mov     ecx, 0x099              ; dump color : blue
  619.         add     ebx, 10
  620.         mov     [gr_pos], ebx
  621.         mcall   SF_DRAW_TEXT
  622.  
  623.         mov     ecx, [MMIO_Map]         ; release the tried page
  624.         mcall   SF_PCI,13
  625.  
  626. mmio_next_bar:
  627.         mov     bh, [MMIO_BAR]
  628.         inc     bh
  629.         cmp     bh,7
  630.         je      @f
  631.  
  632.         mov     [MMIO_BAR], bh
  633.         add     [gr_pos], 10
  634.         jmp     Try_MMIO
  635. ;-----------------------------------------------------------------------------
  636. @@:
  637.         xor     bh,bh
  638.         mov     [MMIO_BAR], bh
  639.         ret
  640. ;-----------------------------------------------------------------------------
  641. store_CR:
  642.         pusha
  643.         mov     edi,[store_text_area_end]
  644.         mov     [edi],word 0A20h ; CR (carriage return) + SPACE
  645.         add     dword [store_text_area_end],2
  646.         popa
  647.         ret
  648. ;-----------------------------------------------------------------------------
  649. store_text:
  650.         pusha
  651.         inc     dword [store_text_area_end]
  652.         mov     esi,edx
  653.         mov     edi,[store_text_area_end]
  654.         push    edi
  655.         xor     eax,eax
  656.         cld
  657. @@:
  658.         lodsb
  659.         test    eax,eax
  660.         jz      @f
  661.         stosb
  662.         inc     dword [store_text_area_end]
  663.         jmp     @r
  664. @@:
  665.         pop     esi
  666.         mov     eax,[store_text_size]
  667.         test    eax,eax
  668.         jz      @f
  669.         sub     edi,esi
  670.         sub     eax,edi
  671.         add     [store_text_area_end],eax
  672. @@:
  673.         popa
  674.         ret
  675. ;-----------------------------------------------------------------------------
  676. store_NA:
  677.         pusha
  678.         mov     ebx,edx
  679.         mcall   SF_DRAW_TEXT,,0x80000000,text_NA
  680.         mov     edi,[store_text_area_end]
  681.         mov     ax,[edx]
  682.         mov     [edi+1],ax
  683.         add     [store_text_area_end],dword 5
  684.         popa
  685.         ret
  686. ;-----------------------------------------------------------------------------
  687. store_2_digits:
  688.         pusha
  689.         inc     [store_text_area_end]
  690.         mov     ebx,ecx
  691.         mov     ecx,2
  692.         mov     edi,[store_text_area_end]
  693.         call    binary_to_hex_string
  694.         add     [store_text_area_end],dword 4
  695.         popa
  696.         ret
  697. ;-----------------------------------------------------------------------------
  698. store_4_digits:
  699.         pusha
  700.         mov     ebx,ecx
  701.         mov     ecx,4
  702.         mov     edi,[store_text_area_end]
  703.         call    binary_to_hex_string
  704.         add     [store_text_area_end],dword 6
  705.         popa
  706.         ret
  707. ;-----------------------------------------------------------------------------
  708. ; ebx - value
  709. ; ecx - digits
  710. ; edi - output string
  711. binary_to_hex_string:
  712.         add     edi,ecx
  713.         dec     edi
  714.         std
  715. .1:
  716.         mov     al,bl
  717.         and     al,0xf
  718.         shr     ebx,4
  719.         cmp     al,9
  720.         jbe     @f
  721.  
  722.         add     al,0x27
  723. @@:
  724.         add     al,0x30
  725.         stosb
  726.         dec     ecx
  727.         jnz     .1
  728.         cld
  729.         ret
  730. ;-----------------------------------------------------------------------------
  731. include 'vendors.inc'
  732. ;-----------------------------------------------------------------------------
  733. ; DATA AREA
  734. DATA
  735.  
  736. Form:   dw 800 ; window width (no more, special for 800x600)
  737.         dw 100 ; window x start
  738.         dw 620 ; window height
  739.         dw 20 ; window y start
  740.  
  741. title   db 'PCI Device Enumerator v 2.3', 0
  742.  
  743. if lang eq it
  744. PCIWin mls \
  745.         '   Don`t forget to enable PCI Access to Applications in Setup Menu.',\
  746.         '',\
  747.         'Versione PCI = x.xx; Ultimo Bus PCI = x',\
  748.         'User MMIO channel = 0F.F:F ',\
  749.         'Numbero di unità PCI =    ',\
  750.         '',\
  751.         'VenID DevID Bus# Dev# Fnc Rev  Class  Subclass/ IRQ                 Compania                    Descrizzione',\
  752.         '                                      Interfaccia',\
  753.         '----- ----- ---- ---- --- ---  -----  --------- --- ------------------------------------------ --------------------------------'
  754.  
  755. bar_ram db 'BARx: MMIO block', 0
  756. bar_io  db 'BARx: porte IO',0
  757. bar_um  db 'BARx: unmapped',0
  758. bar_rom db 'BAR6: Expansion ROM', 0
  759.  
  760. text_save_button:
  761.         db 'Salva lista PCI',0
  762. .1:     db '(Premere S)',0
  763. else
  764. PCIWin mls \
  765.         '   Don`t forget to enable PCI Access to Applications in Setup Menu.',\
  766.         '',\
  767.         'PCI Version  = x.xx; Last PCI Bus = x',\
  768.         'User MMIO channel = 0F.F:F ',\
  769.         'Number of PCI units =    ',\
  770.         '',\
  771.         'VenID DevID Bus# Dev# Fnc Rev  Class  Subclass/ IRQ                 Company                      Description',\
  772.         '                                      Interface',\
  773.         '----- ----- ---- ---- --- ---  -----  --------- --- ------------------------------------------ --------------------------------'
  774.  
  775. bar_ram db 'BARx: MMIO block', 0
  776. bar_io  db 'BARx: IO ports',0
  777. bar_um  db 'BARx: unmapped',0
  778. bar_rom db 'BAR6: Expansion ROM', 0
  779.  
  780. text_save_button:
  781.         db 'Save PCI list',0
  782. .1:     db '(Press S key)',0
  783. end if
  784.  
  785. text_NA:
  786.         db '--',0
  787. ;---------------------------------------------------------------------
  788. system_dir_ProcLib      db '/sys/lib/proc_lib.obj',0
  789.  
  790. ;---------------------------------------------------------------------
  791. l_libs_start:
  792.  
  793. library02  l_libs system_dir_ProcLib+9, library_path, system_dir_ProcLib, ProcLib_import
  794.  
  795. end_l_libs:
  796. ;---------------------------------------------------------------------
  797. align 4
  798. ProcLib_import:
  799. OpenDialog_Init         dd aOpenDialog_Init
  800. OpenDialog_Start        dd aOpenDialog_Start
  801. ;OpenDialog__Version    dd aOpenDialog_Version
  802.         dd      0
  803.         dd      0
  804. aOpenDialog_Init        db 'OpenDialog_init',0
  805. aOpenDialog_Start       db 'OpenDialog_start',0
  806. ;aOpenDialog_Version    db 'Version_OpenDialog',0
  807. ;---------------------------------------------------------------------
  808. align 4
  809. OpenDialog_data:
  810. .type                   dd 0
  811. .procinfo               dd Proc_Info    ;+4
  812. .com_area_name          dd communication_area_name      ;+8
  813. .com_area               dd 0    ;+12
  814. .opendir_pach           dd temp_dir_pach        ;+16
  815. .dir_default_pach       dd communication_area_default_pach      ;+20
  816. .start_path             dd open_dialog_path     ;+24
  817. .draw_window            dd draw_window  ;+28
  818. .status                 dd 0    ;+32
  819. .openfile_pach          dd file_name    ;+36
  820. .filename_area          dd filename_area        ;+40
  821. .filter_area            dd Filter
  822. .x:
  823. .x_size                 dw 420 ;+48 ; Window X size
  824. .x_start                dw 10 ;+50 ; Window X position
  825. .y:
  826. .y_size                 dw 320 ;+52 ; Window y size
  827. .y_start                dw 10 ;+54 ; Window Y position
  828.  
  829. communication_area_name:
  830.         db 'FFFFFFFF_open_dialog',0
  831. open_dialog_path:
  832.         db '/sys/File Managers/opendial',0
  833. communication_area_default_pach:
  834.         db '/sys',0
  835. Filter:
  836. dd      Filter.end - Filter.1
  837. .1:
  838. db      'TXT',0
  839. db      'LOG',0
  840. .end:
  841. dd      0
  842.  
  843. file_default_path:
  844.         db '/sys/'
  845. start_temp_file_name:
  846.         db 'pcidev.txt',0
  847. ;---------------------------------------------------------------------
  848. align   4
  849. fileinfo:
  850. .subfunction    dd 2
  851. .Offset         dd 0
  852. .Offset_1       dd 0
  853. .size           dd 4096
  854. .return         dd 0
  855.                 db 0
  856. .name:          dd file_name
  857. ;-----------------------------------------------------------------------------
  858.  
  859. ; UNINITIALIZED DATA AREA
  860. IM_END:
  861. total           db ?
  862. V_Bus           db ?
  863. V_Dev           db ?
  864. PCI_Version     dw ?
  865. PCI_LastBus     db ?
  866. PCI_Device      dw ?
  867. PCI_Vendor      dw ?
  868. PCI_Bus         db ?
  869. PCI_Dev         db ?
  870. PCI_Rev         db ?
  871. ; don`t change order!!!
  872. PCI_Class       db ?
  873. PCI_SubClass    db ?
  874. PCI_Interface   db ?
  875. PCI_IRQ         db ?
  876.  
  877. align 4
  878. MMIO_Bus        db 255
  879. MMIO_Dev        db 255
  880. MMIO_BAR        db 0
  881. MMIO_allowed    db 1
  882. MMIO_Map        rd 8
  883.  
  884. gr_pos          dd ?
  885.  
  886. store_text_area_start   dd ?
  887. store_text_area_end     dd ?
  888. store_text_size         dd ?
  889.  
  890. extended_key    rb 1
  891. ;---------------------------------------------------------------------
  892. library_path:
  893.         rb 4096
  894. ;---------------------------------------------------------------------
  895. path:
  896.         rb 4096
  897. ;---------------------------------------------------------------------
  898. temp_dir_pach:
  899.         rb 4096
  900. ;---------------------------------------------------------------------
  901. file_name:
  902.         rb 4096
  903. ;---------------------------------------------------------------------
  904. file_name_1:
  905.         rb 4096
  906. ;---------------------------------------------------------------------
  907. filename_area:
  908.         rb 256
  909. ;---------------------------------------------------------------------
  910.         rb 4096
  911. stacktop:
  912. ;---------------------------------------------------------------------
  913. Proc_Info       process_information
  914. ;---------------------------------------------------------------------
  915. I_END:
  916. ;-----------------------------------------------------------------------------
  917.