; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "BSD 2-clause" license.           |
;|_______________________________________________________________________________________|
;
;  Description: KolibriOS system functions and related constants.
;
;  Target OS: KolibriOS
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


sys_drawwindow          =   0     ;  DrawWindow
syscall_setpixel        =   1     ;  SetPixel
sys_getkey              =   2     ;  GetKey
sys_clock               =   3     ;  GetTime
sys_writetext           =   4     ;  WriteText
sys_delay_hs            =   5     ;  DelayHs
sys_openramdiskfile     =   6     ;  OpenRamdiskFile
sys_putimage            =   7     ;  PutImage
sys_button              =   8     ;  DefineButton
sys_cpuusage            =   9     ;  GetProcessInfo
sys_waitforevent        =   10    ;  WaitForEvent
sys_getevent            =   11    ;  CheckForEvent
sys_redrawstat          =   12    ;  BeginDraw and EndDraw
sys_drawrect            =   13    ;  DrawRect
sys_getscreensize       =   14    ;  GetScreenSize
sys_background          =   15    ;  bgr
sys_cachetodiskette     =   16    ;  FlushFloppyCache
sys_getbutton           =   17    ;  GetButton
sys_system              =   18    ;  System Services
sys_midi                =   20    ;  ResetMidi and OutputMidi
sys_setup               =   21    ;  SetMidiBase,SetKeymap,SetShiftKeymap,.
sys_settime             =   22    ;  setting date,time,clock and alarm    ;  clock
sys_wait_event_timeout  =   23    ;  TimeOutWaitForEvent
sys_cdaudio             =   24    ;  PlayCdTrack,StopCd and GetCdPlaylist
sys_getsetup            =   26    ;  GetMidiBase,GetKeymap,GetShiftKeymap,.
sys_date                =   29    ;  GetDate
sys_current_directory   =   30    ;  Get/SetCurrentDirectory
sys_getpixel            =   35    ;  GetPixel
sys_getarea             =   36    ;  GetArea
sys_readmousepos        =   37    ;  GetMousePosition_ScreenRelative,.
syscall_drawline        =   38    ;  DrawLine
sys_getbackground       =   39    ;  GetBackgroundSize,ReadBgrData,.
sys_set_app_param       =   40    ;  WantEvents
sys_get_irq_owner       =   41    ;  GetIrqOwner
sys_get_irq_data        =   42    ;  ReadIrqData
sys_outport             =   43    ;  SendDeviceData
sys_program_irq         =   44    ;  ProgramIrqs
sys_reserve_free_irq    =   45    ;  ReserveIrq and FreeIrq
sys_reserveportarea     =   46    ;  ReservePortArea and FreePortArea
sys_display_number      =   47    ;  WriteNum
sys_display_settings    =   48    ;  SetRedrawType and SetButtonType
sys_apm                 =   49    ;  Advanced Power Management (APM)
sys_random_shaped_window=   50    ;  Window shape & scale
sys_threads             =   51    ;  Threads
sys_stack_driver_stat   =   52    ;  Stack driver status
sys_socket_old          =   53    ;  Socket interface

sys_sound_interface     =   55    ;  Sound interface
sys_pcibios             =   57    ;  PCI BIOS32
sys_file_system         =   58    ;  Common file system interface
sys_IPC                 =   60    ;  Inter Process Communication
sys_gs                  =   61    ;  Direct graphics access
sys_pci                 =   62    ;  PCI functions
sys_msg_board           =   63    ;  System message board
sys_resize_app_memory   =   64    ;  Resize application memory usage
sys_putimage_palette    =   65    ;  PutImagePalette
sys_process_def         =   66    ;  Process definitions - keyboard
sys_window_move         =   67    ;  Window move or resize
sys_f68                 =   68    ;  Some internal services
sys_debug_services      =   69    ;  Debug
sys_file_system_lfn     =   70    ;  Common file system interface, version 2
sys_windowsettings      =   71    ;  Window settings
sys_sendwindowmsg       =   72    ;  Send window message
sys_socket              =   75    ;  http://wiki.kolibrios.org/wiki/New_network_api
sys_end                 =   -1    ;  end application




; sys_socket subfunctions

sockOpen        = 0
sockClose       = 1
sockBind        = 2
sockListen      = 3
sockConnect     = 4
sockAccept      = 5
sockSend        = 6
sockReceive     = 7
sockSetOptions  = 8
sockGetOptions  = 9
sockPair        = 10


; sys_file_system_lfn subfunctions

fsfRead        = 0
fsfReadDir     = 1
fsfCreate      = 2
fsfWrite       = 3
fsfSetSize     = 4
fsfFileInfo    = 5
fsfSetAttr     = 6
fsfExec        = 7
fsfDel         = 8      ; for files and directories
fsfCreateDir   = 9






; windows/thread events

eventRedraw             = 1
eventKeyboard           = 2
eventGUIButton          = 3
eventReserved           = 4     ; reserved, not used
eventDesktopRepainted   = 5
eventMouse              = 6     ; move or key pressed
eventIPC                = 7
eventNetwork            = 8
eventDebug              = 9
eventIRQ0               = 16
eventIRQ1               = 17
eventIRQ2               = 18
eventIRQ3               = 19
eventIRQ4               = 20
eventIRQ5               = 21
eventIRQ6               = 22
eventIRQ7               = 23
eventIRQ8               = 24
eventIRQ9               = 25
eventIRQ10              = 26
eventIRQ11              = 27
eventIRQ12              = 28
eventIRQ13              = 29
eventIRQ14              = 30
eventIRQ15              = 31

emaskRedraw             = 1
emaskKeyboard           = 2
emaskGUIButton          = 4
emaskReserved           = 8
emaskDesktopRedraw      = 16
emaskMouse              = 32
emaskIPCEvent           = 64
emaskNetwork            = 128
emaskDebug              = 256


struct __TThreadInfo
  .cpu_usage   dd ?
  .zposWindow  dw ?
  .nWindowSlot dw ?
  .reserve1    dw ?
  .ProcessName rb 11
  .reserve2    db ?
  .processAddr dd ?
  .processSize dd ?
  .TID         dd ?
  .wndPosX     dd ?
  .wndPosY     dd ?
  .wndSizeX    dd ?
  .wndSizeY    dd ?
  .ThreadState dw ?
  .reserve3    dw ?
  .ClientPosX  dd ?
  .ClientPosY  dd ?
  .ClientWidth dd ?
  .ClientHeight dd ?
  .WindowState  db ?
  .EventMask    dd ?
  .min_size = $$ - $
                rb 1024 - .min_size
ends


accessRead  = 1
accessWrite = 2



; Error codes

errSuccess              = 0

errBaseNotDefined       = 1   ; base and/or partition of a hard disk is not defined
                              ; (by subfunctions 7, 8 of function 21)

errFunctionNotSupported = 2   ; function is not supported for the given file system
errUnknownFileSystem    = 3   ; unknown file system
;errReserved             = 4   ; reserved, is never returned in the current implementation
errFileNotFound         = 5   ; file not found
errEndOfFile            = 6   ; end of file, EOF
errBadPointer           = 7   ; pointer lies outside of application memory
errDiskFull             = 8   ; disk is full
errBadFat               = 9   ; FAT table is destroyed
errAccessDenied         = 10  ; access denied
errDeviceError          = 11  ; device error


errFileAlreadyExists    = 100   ; FreshLib error code on faCreateOnly

; Application start functions can return also following errors:

errNotEnoughMemory      = 30  ; not enough memory
errNotExecutable        = 31  ; file is not executable
errTooManyProcesses     = 32  ; too many processes
