Rev 2122 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2120 | clevermous | 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 | } |
||
57 | struc DISKMEDIAINFO |
||
58 | { |
||
59 | .flags dd ? |
||
60 | DISK_MEDIA_READONLY = 1 |
||
61 | .sectorsize dd ? |
||
62 | .capacity dq ? |
||
63 | } |
||
64 | void DiskDel(void* hDisk); |
||
65 | ; This function informs the kernel that the disk should be deleted from the |
||
66 | ; system. This function removes the disk from the global file system; however, |
||
67 | ; it is possible that active operations with the disk are still running. When |
||
68 | ; the disk is actually removed, the kernel calls the 'close' function, which |
||
69 | ; can free all device-related resources. |
||
70 | void DiskMediaChanged(void* hDisk, int newstate); |
||
71 | ; This function informs the kernel that a media has been inserted, removed or |
||
72 | ; changed. 'newstate' should be zero if currently there is no media inserted |
||
73 | ; and nonzero in the other case. This function must not be called with nonzero |
||
74 | ; 'newstate' from any of callbacks. This function must not be called if another |
||
75 | ; call to this function is active. |