Subversion Repositories Kolibri OS

Rev

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

  1. All functions are stdcall unless mentioned otherwise.
  2.  
  3. === Disk ===
  4. The kernel exports the functions 'DiskAdd', 'DiskMediaChanged', 'DiskDel' for
  5. drivers. They must be called in the following order: DiskAdd, then zero or
  6. more DiskMediaChanged, then optionally DiskDel. The driver must not call
  7. two functions in parallel, including two calls to DiskMediaChanged.
  8.  
  9. void* DiskAdd(DISKFUNC* functions, const char* name, void* userdata, int flags);
  10. ; The pointer 'functions' must be valid at least until the disk will be deleted
  11. ; (until DISKFUNC.close is called).
  12. ; The pointer 'name' can be invalid after this function returns.
  13. ; It should point to ASCIIZ-string without leading '/' in latin lowercase and
  14. ; digits, like 'usbhd0'.
  15. ; The value 'userdata' is any pointer-sized data, passed as is to all
  16. ; callbacks.
  17. DISK_NO_INSERT_NOTIFICATION = 1
  18. ; The bitfield 'flags' has currently only one bit defined. If it is set, the
  19. ; driver will never call DiskMediaChanged(hDisk, true), so the kernel must scan
  20. ; for media insertion when the operation is requested.
  21. struc DISKFUNC
  22. {
  23.   .strucsize  dd ?
  24.   .close      dd ?
  25. ; void close(void* userdata);
  26. ; Optional.
  27. ; The last function that is called for the given disk. The kernel calls it when
  28. ; the kernel has finished all operations with the disk and it is safe to free
  29. ; all driver-specific data identified by 'userdata'.
  30.   .closemedia dd ?
  31. ; void closemedia(void* userdata);
  32. ; Optional.
  33. ; The kernel calls this function when it finished all processing with the
  34. ; current media. If media is removed, the driver should decline all requests
  35. ; to that media with DISK_STATUS_NO_MEDIA, even if new media is inserted,
  36. ; until this function is called. If media is removed, a new call to
  37. ; DiskMediaChanged(hDisk, true) is not allowed until this function is called.
  38.   .querymedia dd ?
  39. ; int querymedia(void* userdata, DISKMEDIAINFO* info);
  40. ; return value: 0 = success, otherwise = error
  41.   .read       dd ?
  42. ; int read(void* userdata, void* buffer, __int64 startsector,
  43. ;          int* numsectors);
  44. ; return value: 0 = success, otherwise = error
  45.   .write      dd ?
  46. ; int write(void* userdata, const void* buffer, __int64 startsector,
  47. ;           int* numsectors);
  48. ; Optional.
  49. ; return value: 0 = success, otherwise = error
  50.   .flush      dd ?
  51. ; int flush(void* userdata);
  52. ; Optional.
  53. ; Flushes the hardware cache, if it exists. Note that a driver should not
  54. ; implement a software cache for read/write, since they are called from the
  55. ; kernel cache manager.
  56.   .adjust_cache_size dd ?
  57. ; unsigned int adjust_cache_size(unsigned int suggested_size);
  58. ; Optional.
  59. ; Returns the cache size for this device in bytes. 0 = disable cache.
  60. }
  61. struc DISKMEDIAINFO
  62. {
  63.   .flags      dd ?
  64. DISK_MEDIA_READONLY = 1
  65.   .sectorsize dd ?
  66.   .capacity   dq ?
  67. }
  68. void DiskDel(void* hDisk);
  69. ; This function informs the kernel that the disk should be deleted from the
  70. ; system. This function removes the disk from the global file system; however,
  71. ; it is possible that active operations with the disk are still running. When
  72. ; the disk is actually removed, the kernel calls the 'close' function, which
  73. ; can free all device-related resources.
  74. void DiskMediaChanged(void* hDisk, int newstate);
  75. ; This function informs the kernel that a media has been inserted, removed or
  76. ; changed. 'newstate' should be zero if currently there is no media inserted
  77. ; and nonzero in the other case. This function must not be called with nonzero
  78. ; 'newstate' from any of callbacks. This function must not be called if another
  79. ; call to this function is active.
  80.  
  81. === Timers ===
  82. Timers allow to schedule a function call to some time in the future, once
  83. or periodically. A timer function can do anything, including adding/removing
  84. other timers and itself, but it should not run time-consuming tasks, since that
  85. would block the processing thread for a long time; for such tasks it is
  86. recommended to create new thread.
  87.  
  88. void* TimerHS(unsigned int deltaStart, unsigned int interval,
  89.               void* timerFunc, void* userData);
  90. ; Registers a timer which is activated in (deltaStart == 0 ? deltaStart :
  91. ; interval) 1/100ths of second starting from the current time. If interval
  92. ; is zero, this timer is automatically deleted when activated. Otherwise,
  93. ; this timer will be activated every (interval) 1/100ths of second from the
  94. ; first activation. Activated timer calls timerFunc(userData) as stdcall.
  95. ; Returned value: NULL = failed, otherwise = timer handle which can be passed
  96. ; to CancelTimerHS.
  97. void CancelTimerHS(void* hTimer);
  98. ; Cancels previously registered timer.
  99.