Subversion Repositories Kolibri OS

Rev

Rev 1508 | Rev 1560 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                              ;;
  3. ;; Copyright (C) 2010 KolibriOS team.     All rights reserved.  ;;
  4. ;; Distributed under terms of the GNU General Public License    ;;
  5. ;;                                                              ;;
  6. ;;                                                              ;;
  7. ;;  PCIe.INC                                                    ;;
  8. ;;                                                              ;;
  9. ;;  Extended PCI express services                               ;;
  10. ;;                                                              ;;
  11. ;;                  art_zh  <artem@jerdev.co.uk>                ;;
  12. ;;                                                              ;;
  13. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  14.  
  15. $Revision: 1463 $
  16.  
  17. ;***************************************************************************
  18. ;   Function
  19. ;      pci_ext_config:
  20. ;
  21. ;   Description
  22. ;       PCIe extended (memory-mapped) config space detection
  23. ;
  24. ;   WARNINGs:
  25. ;       1) Very Experimental!
  26. ;       2) direct HT-detection (no ACPI or BIOS service used)
  27. ;       3) Only AMD/HT processors currently supported
  28. ;
  29. ;***************************************************************************
  30.  
  31. align 4
  32. mmio_pcie_cfg_addr      dd      0x00000000      ; pcie space may be defined here
  33. mmio_pcie_cfg_lim       dd      0x000FFFFF      ; upper pcie space address
  34. mmio_pcie_cfg_pdes      dw      0               ; number of PDEs to map the space
  35. PCIe_bus_range          dw      0               ; the Bus range: power-of-2 Megabytes
  36.  
  37.  
  38. align 4
  39. pci_ext_config:
  40.         mov     ebx, [mmio_pcie_cfg_addr]
  41.         or      ebx,ebx
  42.         jz      @f
  43.         or      ebx, 0x7FFFFFFF         ; required by PCI-SIG standards
  44.         jnz     .pcie_failed
  45.         add     ebx, 0x0FFFFC
  46.         cmp     ebx, [mmio_pcie_cfg_lim]; is the space limit correct?
  47.         ja      .pcie_failed
  48.         jmp     .pcie_cfg_mapped
  49. @@:
  50.         mov     ebx, [cpu_vendor]
  51.         cmp     ebx, dword [AMD_str]
  52.         jne     .pcie_failed
  53.         mov     bx, 0xC184              ; dev = 24, fn = 01, reg = 84h
  54.  
  55. .check_HT_mmio:
  56.         mov     cx, bx
  57.         mov     ax, 0x0002              ; bus = 0, 1dword to read
  58.         call    pci_read_reg
  59.         mov     bx, cx
  60.         sub     bl, 4
  61.         and     al, 0x80                ; check the NP bit
  62.         jz      .no_pcie_cfg
  63.         shl     eax, 8                  ; bus:[27..20], dev:[19:15]
  64.         or      eax, 0x00007FFC         ; fun:[14..12], reg:[11:2]
  65. ;       mov     [mmio_pcie_cfg_lim], eax
  66.         mov     cl, bl
  67.         mov     ax, 0x0002              ; bus = 0, 1dword to read
  68.         call    pci_read_reg
  69.         mov     bx, cx
  70.         test    al, 0x03                ; MMIO Base RW enabled?
  71.         jz      .no_pcie_cfg
  72.         test    al, 0x0C                ; MMIO Base locked?
  73.         jnz     .no_pcie_cfg
  74.         xor     al, al
  75.         shl     eax, 8
  76.         test    eax, 0x000F0000         ; MMIO Base must be bus0-aligned
  77.         jnz     .no_pcie_cfg
  78.         mov     [mmio_pcie_cfg_addr], eax
  79. ;       add     eax, 0x000FFFFC
  80. ;       sub     eax,[mmio_pcie_cfg_lim] ; MMIO must cover at least one bus
  81. ;       ja      .no_pcie_cfg
  82.  
  83. ;       -- it looks like a true PCIe config space;
  84.  
  85. .pcie_cfg_mapped:
  86.        
  87.         mov     esi, boot_pcie_ok
  88.         call    boot_log
  89.         ret     ; <<<<<<<<<<< OK >>>>>>>>>>>
  90.        
  91. .no_pcie_cfg:
  92.  
  93.         xor     eax, eax
  94.         mov     [mmio_pcie_cfg_addr], eax
  95.         mov     [mmio_pcie_cfg_lim],  eax
  96.         add     bl, 12
  97.         cmp     bl, 0xC0                ; MMIO regs lay below this offset
  98.         jb      .check_HT_mmio
  99. .pcie_failed:
  100.         mov     esi, boot_pcie_fail
  101.         call    boot_log
  102.         ret     ; <<<<<<<<< FAILURE >>>>>>>>>
  103.  
  104.