Subversion Repositories Kolibri OS

Rev

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

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