Subversion Repositories Kolibri OS

Rev

Rev 4 | Rev 40 | 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. uglobal
  7.   pushed_regs rd 1
  8. endg
  9.  
  10. align 32
  11. i40:
  12.       pushad
  13.  
  14.       push  ds
  15.       mov   ax,word os_data
  16.       mov   ds,ax
  17.       mov   es,ax
  18.       mov   [pushed_regs],esp
  19.       add   dword [pushed_regs],4
  20.       cli
  21.  
  22.       mov    eax, [0x3000]
  23.       mov    edi, eax
  24.       shl    edi, 8
  25.       mov    [edi+0x80000+0xB0],eax  ; used i40 handler
  26.  
  27.       ; for syscall trace function
  28.       call  save_registers
  29.  
  30.       mov   esi,[pushed_regs]
  31.  
  32.       ; load first 3 registers
  33.       mov   eax,[esi+28]
  34.       mov   ebx,[esi+16]
  35.       mov   ecx,[esi+24]
  36.  
  37.       ; save current registers
  38.       ; stack may be modified by a system function to return some value to caller!
  39.       pushad
  40.  
  41.       ; load all registers from TSS of the application, in crossed order (why?)
  42.       mov   edi,[esi+28]
  43.       mov   eax,[esi+16]
  44.       mov   ebx,[esi+24]
  45.       mov   ecx,[esi+20]
  46.       mov   edx,[esi+4]
  47.       mov   esi,[esi+0]
  48.  
  49.       ; enable interupts  -  a task switch or an IRQ _CAN_ interrupt i40 handler
  50.       sti
  51.       ; eax doesn't need to be saved, but...
  52.       push   eax
  53.       and    edi,0xff
  54.       call   dword [servetable+edi*4]
  55.       pop    eax
  56.       cli
  57.        
  58.       ; return saved and probably even changed regs
  59.       popad
  60.  
  61.       ; modify 3 program's registers (in its TSS)
  62.       mov   [esi+28],eax  
  63.       mov   [esi+16],ebx
  64.       mov   [esi+24],ecx
  65.  
  66.       xor    eax, eax
  67.       mov    edi, [0x3000]          ; no syscall interrupt in use anymore
  68.       shl    edi, 8
  69.       mov    [edi+0x80000+0xB0],eax
  70.  
  71.       pop     eax
  72.       mov     ds,ax
  73.       mov     es,ax
  74.      
  75.       popad
  76.       iretd
  77.  
  78. align 4
  79. save_registers:
  80.       mov   esi, [0x3010]
  81.       mov   eax, [esi+0x4] ; load PID
  82.       mov   esi, [pushed_regs]
  83.       inc   [save_syscall_count]
  84.       mov   edi,[save_syscall_count]
  85.       and   edi,0xF
  86.       shl   edi,6
  87.       add   edi,save_syscall_data+32
  88.       mov   [edi-32],eax
  89.       mov   ecx,32 / 4
  90.       cld
  91.       rep   movsd
  92.       ret
  93.  
  94. uglobal
  95.   save_syscall_count  dd 0x0
  96. endg
  97.  
  98. label save_syscall_data dword at 0x5000
  99.  
  100.  
  101. iglobal
  102.   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  103.   ;; SYSTEM FUNCTIONS TABLE ;;
  104.   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  105.  
  106.   align 4
  107.   servetable:
  108.  
  109.       dd sys_drawwindow          ; 0-DrawWindow
  110.       dd syscall_setpixel        ; 1-SetPixel
  111.       dd sys_getkey              ; 2-GetKey
  112.       dd sys_clock               ; 3-GetTime
  113.       dd syscall_writetext       ; 4-WriteText
  114.       dd delay_hs                ; 5-DelayHs
  115.       dd syscall_openramdiskfile ; 6-OpenRamdiskFile
  116.       dd syscall_putimage        ; 7-PutImage
  117.       dd sys_button              ; 8-DefineButton
  118.       dd sys_cpuusage            ; 9-GetProcessInfo
  119.       dd sys_waitforevent        ; 10-WaitForEvent
  120.       dd sys_getevent            ; 11-CheckForEvent
  121.       dd sys_redrawstat          ; 12-BeginDraw and EndDraw
  122.       dd syscall_drawrect        ; 13-DrawRect
  123.       dd syscall_getscreensize   ; 14-GetScreenSize
  124.       dd sys_background          ; 15-bgr
  125.       dd sys_cachetodiskette     ; 16-FlushFloppyCache
  126.       dd sys_getbutton           ; 17-GetButton
  127.       dd syscall_system          ; 18-Shutdown,KillApp,WindowActivate
  128.       dd syscall_startapp        ; 19-StartApp
  129.       dd sys_midi                ; 20-ResetMidi and OutputMidi
  130.       dd sys_setup               ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,.
  131.       dd sys_settime             ; 22-setting date,time,clock and alarm-clock
  132.       dd sys_wait_event_timeout  ; 23-TimeOutWaitForEvent
  133.       dd syscall_cdaudio         ; 24-PlayCdTrack,StopCd and GetCdPlaylist
  134.       dd sys_sb16                ; 25-SetSb16
  135.       dd sys_getsetup            ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,.
  136.       dd sys_wss                 ; 27-SetWssMainVol and SetWssCdVol
  137.       dd sys_sb16II              ; 28-SetSb16
  138.       dd sys_date                ; 29-GetDate
  139.       dd syscall_readhd          ; 30-ReadHd
  140.       dd syscall_starthdapp      ; 31-StartHdApp
  141.       dd syscall_delramdiskfile  ; 32-DelRamdiskFile
  142.       dd syscall_writeramdiskfile; 33-WriteRamdiskFile
  143.       dd read_floppy_file        ; 34-ReadFloppyDrive
  144.       dd syscall_getpixel        ; 35-GetPixel
  145.       dd syscall_readstring      ; 36-ReadString (not yet ready)
  146.       dd readmousepos            ; 37-GetMousePosition_ScreenRelative,.
  147.       dd syscall_drawline        ; 38-DrawLine
  148.       dd sys_getbackground       ; 39-GetBackgroundSize,ReadBgrData,.
  149.       dd set_app_param           ; 40-WantEvents
  150.       dd syscall_getirqowner     ; 41-GetIrqOwner
  151.       dd get_irq_data            ; 42-ReadIrqData
  152.       dd sys_outport             ; 43-SendDeviceData
  153.       dd sys_programirq          ; 44-ProgramIrqs
  154.       dd reserve_free_irq        ; 45-ReserveIrq and FreeIrq
  155.       dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea
  156.       dd display_number          ; 47-WriteNum
  157.       dd display_settings        ; 48-SetRedrawType and SetButtonType
  158.       dd syscall_appints         ; 49-AppInts
  159.       dd random_shaped_window    ; 50-Window shape & scale
  160.       dd syscall_threads         ; 51-Threads
  161.       dd stack_driver_stat       ; 52-Stack driver status
  162.       dd socket                  ; 53-Socket interface
  163.       dd user_events             ; 54-User events
  164.       dd sound_interface         ; 55-Sound interface
  165.       dd write_to_hd             ; 56-Write a file to hd
  166.       dd delete_from_hd          ; 57-Delete a file from hd
  167.       dd file_system             ; 58-Common file system interface
  168.       dd sys_trace               ; 59-System call trace
  169.       dd new_sys_ipc             ; 60-Inter Process Communication
  170.       dd sys_gs                  ; 61-Direct graphics access
  171.       dd sys_pci                 ; 62-PCI functions
  172.       dd sys_msg_board           ; 63-System message board
  173.       dd sys_resize_app_memory   ; 64-Resize application memory usage
  174.       dd undefined_syscall       ; 65-UTF
  175.       dd sys_process_def         ; 66-Process definitions - keyboard
  176.       dd sys_window_move         ; 67-Window move or resize
  177.       dd sys_internal_services   ; 68-Some internal services
  178.  
  179.   times 255 - ( ($-servetable) /4 )  dd undefined_syscall
  180.  
  181.       dd sys_end                 ; -1-end application
  182. endg
  183.  
  184.