Subversion Repositories Kolibri OS

Rev

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

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