Subversion Repositories Kolibri OS

Rev

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

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