Subversion Repositories Kolibri OS

Rev

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

  1. ;
  2. ; Kolibri Fast Calls test
  3. ;
  4. ;   Compile with FASM for Kolibri
  5. ;
  6. ;
  7. use32
  8. org     0x0
  9.         db    'MENUET01'
  10.         dd     0x01
  11.         dd     START
  12.         dd     I_END
  13.         dd     0x1000
  14.         dd     0x1000
  15.         dd     0x0, 0x0
  16.  
  17. include 'macros.inc'
  18. include 'debug.inc'
  19.  
  20. START:  print   'Please wait'
  21.         ; ÷åðåç áûñòðûé âûçîâ (SYSENTER)
  22.         __CPU_type      equ     p6
  23. test1:  mov     eax, 1
  24.         cpuid
  25.         test    edx, 0x800
  26.         jnz     .ok
  27.         dps     'unsupported     '
  28.         jmp     .end
  29. .ok:   
  30.         xor     eax, eax
  31.         cpuid
  32.         rdtsc
  33.         mov     [old_tsc], eax
  34.         mov     [old_tsc + 4], edx
  35.        
  36.         mov     ebx, 0x100000
  37.         align   32
  38. .nxt:   mcall   19              ; ôóíêöèÿ ïóñòûøêà
  39.                                 ; ïîðòÿòñÿ ecx, edx
  40.         dec     ebx
  41.         jnz     .nxt
  42.  
  43.         xor     eax, eax
  44.         cpuid
  45.         rdtsc
  46.         cmp     eax, [old_tsc]
  47.         jnb     @f
  48.         dec     edx
  49. @@:     sub     eax, [old_tsc]
  50.         sub     edx, [old_tsc + 4]
  51.         debug_print_hex edx
  52.         debug_print_hex eax
  53. .end:   print   ' <- Fast call (SYSENTER)'
  54.        
  55.         ;----------------------------------------------
  56.         ; ÷åðåç áûñòðûé âûçîâ (SYSCALL)
  57.         __CPU_type      equ     k6
  58. test2:  xor     eax, eax
  59.         cpuid
  60.         cmp     ecx, "cAMD"
  61.         je      .ok
  62. .nf:    dps     'unsupported     '
  63.         jmp     .end
  64. .ok:    mov     eax, 0x80000001
  65.         cpuid
  66.         test    edx, 0x800  ; bit_11 - SYSCALL/SYSRET support
  67.         jz      .nf
  68.        
  69.         xor     eax, eax
  70.         cpuid
  71.         rdtsc
  72.         mov     [old_tsc], eax
  73.         mov     [old_tsc + 4], edx
  74.        
  75.         mov     ebx, 0x100000
  76.         align   32
  77. .nxt:   mcall   19              ; ôóíêöèÿ ïóñòûøêà
  78.        
  79.         dec     ebx
  80.         jnz     .nxt
  81.  
  82.         xor     eax, eax
  83.         cpuid
  84.         rdtsc
  85.         cmp     eax, [old_tsc]
  86.         jnb     @f
  87.         dec     edx
  88. @@:     sub     eax, [old_tsc]
  89.         sub     edx, [old_tsc + 4]
  90.         debug_print_hex edx
  91.         debug_print_hex eax
  92. .end:   print   ' <- Fast call (SYSCALL)'
  93.         ;----------------------------------------------
  94.         ; ÷åðåç øëþç ïðåðûâàíèÿ
  95.         __CPU_type      equ     p5
  96.         xor     eax, eax
  97.         cpuid
  98.         rdtsc
  99.         mov     [old_tsc], eax
  100.         mov     [old_tsc + 4], edx
  101.        
  102. test3:  mov     ebx, 0x100000
  103.         align   32
  104. .nxt:   mcall   19              ; ôóíêöèÿ ïóñòûøêà
  105.         dec     ebx
  106.         jnz     .nxt
  107.        
  108.         xor     eax, eax
  109.         cpuid
  110.         rdtsc
  111.         cmp     eax, [old_tsc]
  112.         jnb     @f
  113.         dec     edx
  114. @@:     sub     eax, [old_tsc]
  115.         sub     edx, [old_tsc + 4]
  116.         debug_print_hex edx
  117.         debug_print_hex eax
  118.         print   ' <- Interrupt'
  119.  
  120.         mcall -1
  121. ;---------------------------------------------
  122. old_tsc:        dd      0, 0
  123. I_END: