Subversion Repositories Kolibri OS

Rev

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

  1. $Revision: 434 $
  2. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3. ;;                                                              ;;
  4. ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
  5. ;; Distributed under terms of the GNU General Public License    ;;
  6. ;;                                                              ;;
  7. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8.  
  9. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  10. ;;                                                            ;;
  11. ;;                   SYSTEM CALL ENTRY                        ;;
  12. ;;                                                            ;;
  13. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  14.  
  15. align 32
  16. i40:
  17. ; diamond, 27.03.2007: handler does not require disabled interrupts
  18. ;                      so interrupts remain enabled when calling int 0x40
  19.       push  ds es
  20.       pushad
  21.       cld
  22.  
  23.       mov   ax,word os_data
  24.       mov   ds,ax
  25.       mov   es,ax
  26.  
  27.       ; load all registers in crossed order
  28.         mov     eax, ebx
  29.         mov     ebx, ecx
  30.         mov     ecx, edx
  31.         mov     edx, esi
  32.         mov     esi, edi
  33.         mov     edi, [esp+28]
  34.  
  35.       ; enable interupts  -  a task switch or an IRQ _CAN_ interrupt i40 handler
  36. ;      sti
  37.       push  eax
  38.       and   edi,0xff
  39.       call  dword [servetable+edi*4]
  40.       pop   eax
  41. ;      cli
  42.  
  43.       popad
  44.       pop   es ds
  45.       iretd
  46.  
  47.  
  48. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  49. ;;                                                            ;;
  50. ;;                     SYSENTER ENTRY                         ;;
  51. ;;                                                            ;;
  52. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  53.  
  54. ;uglobal
  55. ;times  100 db ?
  56. ;sysenter_stack:
  57. ;endg
  58.  
  59. align 32
  60. SYSENTER_VAR    equ     0
  61. sysenter_entry:
  62.         ; Íàñòðàèâàåì ñòåê
  63.      ;   cli                   sysenter clear IF
  64.      ;   push    eax
  65.      ;   mov     eax, [ss:CURRENT_TASK]
  66.      ;   shl     eax, 8
  67.      ;   mov     eax, [ss:SLOT_BASE + eax + APPDATA.pl0_stack]
  68.      ;   lea     esp, [eax + RING0_STACK_SIZE]           ; configure ESP
  69.      ;   mov     eax, [ss:sysenter_stack - 4]            ; eax - original eax, from app
  70.         mov     esp, [ss:CURRENT_RING0_ESP]
  71.  
  72.         sti
  73.         ;------------------
  74.         push    ds es
  75.         pushad
  76.         cld
  77.  
  78.         mov     ax, word os_data
  79.         mov     ds, ax
  80.         mov     es, ax
  81.  
  82.         mov     eax, ebx
  83.         mov     ebx, ecx
  84.         mov     ecx, edx
  85.         mov     edx, esi
  86.         mov     esi, edi
  87.         mov     edi, [esp + 28]
  88.  
  89.         push    eax
  90.         and     edi, 0xff
  91.         call    dword [servetable + edi * 4]
  92.         pop     eax
  93.  
  94.         popad
  95.         pop     es ds
  96.         ;------------------
  97.         mov     edx, [SYSENTER_VAR]             ; eip
  98.         mov     ecx, [SYSENTER_VAR + 4] ; esp
  99.         sysexit
  100.  
  101. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  102. ;;                                                            ;;
  103. ;;                     SYSCALL ENTRY                          ;;
  104. ;;                                                            ;;
  105. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  106. align 32
  107. syscall_entry:
  108.  
  109.   ;     cli                 syscall clear IF
  110.         xchg    esp, [ss:CURRENT_RING0_ESP]
  111.         push    ecx
  112.         lea     ecx, [esp+4]
  113.         xchg    ecx, [ss:CURRENT_RING0_ESP]
  114.         sti
  115.         push    ecx
  116.         mov     ecx, [ecx]
  117.  
  118.   ;      mov     [ss:sysenter_stack - 4], eax
  119.   ;      mov     eax, [ss:CURRENT_TASK]
  120.   ;      shl     eax, 8
  121.   ;      mov     eax, [ss:SLOT_BASE + eax + APPDATA.pl0_stack]
  122.   ;      lea     esp, [eax + RING0_STACK_SIZE]           ; configure ESP
  123.   ;      mov     eax, [ss:sysenter_stack - 4]            ; eax - original eax, from app
  124.  
  125.         ;------------------
  126.         push    ds es
  127.         pushad
  128.         cld
  129.  
  130.         mov     ax, word os_data
  131.         mov     ds, ax
  132.         mov     es, ax
  133.  
  134.         mov     eax, ebx
  135.         mov     ebx, ecx
  136.         mov     ecx, edx
  137.         mov     edx, esi
  138.         mov     esi, edi
  139.         mov     edi, [esp + 28]
  140.  
  141.         push    eax
  142.         and     edi, 0xff
  143.         call    dword [servetable + edi * 4]
  144.         pop     eax
  145.  
  146.         popad
  147.         pop     es ds
  148.         ;------------------
  149.  
  150.         mov     ecx, [ss:esp+4]
  151.         pop     esp
  152.         sysret
  153.  
  154. iglobal
  155.   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  156.   ;; SYSTEM FUNCTIONS TABLE ;;
  157.   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  158.  
  159.   align 4
  160.   servetable:
  161.  
  162.       dd sys_drawwindow          ; 0-DrawWindow
  163.       dd syscall_setpixel        ; 1-SetPixel
  164.       dd sys_getkey              ; 2-GetKey
  165.       dd sys_clock               ; 3-GetTime
  166.       dd syscall_writetext       ; 4-WriteText
  167.       dd delay_hs                ; 5-DelayHs
  168.       dd syscall_openramdiskfile ; 6-OpenRamdiskFile
  169.       dd syscall_putimage        ; 7-PutImage
  170.       dd sys_button              ; 8-DefineButton
  171.       dd sys_cpuusage            ; 9-GetProcessInfo
  172.       dd sys_waitforevent        ; 10-WaitForEvent
  173.       dd sys_getevent            ; 11-CheckForEvent
  174.       dd sys_redrawstat          ; 12-BeginDraw and EndDraw
  175.       dd syscall_drawrect        ; 13-DrawRect
  176.       dd syscall_getscreensize   ; 14-GetScreenSize
  177.       dd sys_background          ; 15-bgr
  178.       dd sys_cachetodiskette     ; 16-FlushFloppyCache
  179.       dd sys_getbutton           ; 17-GetButton
  180.       dd sys_system              ; 18-System Services
  181.       dd paleholder;undefined_syscall       ; 19-reserved
  182.       dd sys_midi                ; 20-ResetMidi and OutputMidi
  183.       dd sys_setup               ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,.
  184.       dd sys_settime             ; 22-setting date,time,clock and alarm-clock
  185.       dd sys_wait_event_timeout  ; 23-TimeOutWaitForEvent
  186.       dd syscall_cdaudio         ; 24-PlayCdTrack,StopCd and GetCdPlaylist
  187.       dd sys_sb16                ; 25-SetSb16
  188.       dd sys_getsetup            ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,.
  189.       dd undefined_syscall       ; 27-reserved
  190.       dd sys_sb16II              ; 28-SetSb16
  191.       dd sys_date                ; 29-GetDate
  192.       dd undefined_syscall       ; 30-reserved
  193.       dd undefined_syscall       ; 31-reserved
  194.       dd syscall_delramdiskfile  ; 32-DelRamdiskFile
  195.       dd syscall_writeramdiskfile; 33-WriteRamdiskFile
  196.       dd undefined_syscall       ; 34-reserved
  197.       dd syscall_getpixel        ; 35-GetPixel
  198.       dd syscall_readstring      ; 36-ReadString (not yet ready)
  199.       dd readmousepos            ; 37-GetMousePosition_ScreenRelative,.
  200.       dd syscall_drawline        ; 38-DrawLine
  201.       dd sys_getbackground       ; 39-GetBackgroundSize,ReadBgrData,.
  202.       dd set_app_param           ; 40-WantEvents
  203.       dd syscall_getirqowner     ; 41-GetIrqOwner
  204.       dd get_irq_data            ; 42-ReadIrqData
  205.       dd sys_outport             ; 43-SendDeviceData
  206.       dd sys_programirq          ; 44-ProgramIrqs
  207.       dd reserve_free_irq        ; 45-ReserveIrq and FreeIrq
  208.       dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea
  209.       dd display_number          ; 47-WriteNum
  210.       dd display_settings        ; 48-SetRedrawType and SetButtonType
  211.       dd sys_apm                 ; 49-Advanced Power Management (APM)
  212.       dd random_shaped_window    ; 50-Window shape & scale
  213.       dd syscall_threads         ; 51-Threads
  214.       dd stack_driver_stat       ; 52-Stack driver status
  215.       dd socket                  ; 53-Socket interface
  216.       dd user_events             ; 54-User events
  217.       dd sound_interface         ; 55-Sound interface
  218.       dd undefined_syscall       ; 56-reserved
  219.       dd undefined_syscall       ; 57-reserved
  220.       dd file_system             ; 58-Common file system interface
  221.       dd undefined_syscall       ; 59-reserved
  222.       dd sys_IPC                 ; 60-Inter Process Communication
  223.       dd sys_gs                  ; 61-Direct graphics access
  224.       dd sys_pci                 ; 62-PCI functions
  225.       dd sys_msg_board           ; 63-System message board
  226.       dd sys_resize_app_memory   ; 64-Resize application memory usage
  227.       dd syscall_putimage_palette; 65-PutImagePalette
  228.       dd sys_process_def         ; 66-Process definitions - keyboard
  229.       dd sys_window_move         ; 67-Window move or resize
  230.       dd new_services            ; 68-Some internal services
  231.       dd sys_debug_services      ; 69-Debug
  232.       dd file_system_lfn         ; 70-Common file system interface, version 2
  233.       dd syscall_windowsettings  ; 71-Window settings
  234.  
  235.   times 255 - ( ($-servetable) /4 )  dd undefined_syscall
  236.  
  237.       dd sys_end                 ; -1-end application
  238. endg
  239.