Subversion Repositories Kolibri OS

Rev

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

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