Rev 2288 | Rev 2455 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2288 | Rev 2381 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2011. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2011. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line 8... | ||
8 | $Revision: 2288 $ |
8 | $Revision: 2381 $ |
9 | 9 | ||
10 | ; ============================================================================= |
10 | ; ============================================================================= |
11 | ; ================================= Constants ================================= |
11 | ; ================================= Constants ================================= |
Line 32... | Line 32... | ||
32 | ; ============================================================================= |
32 | ; ============================================================================= |
33 | ; This structure defines all callback functions for working with the physical |
33 | ; This structure defines all callback functions for working with the physical |
34 | ; device. They are implemented by a driver. Objects with this structure reside |
34 | ; device. They are implemented by a driver. Objects with this structure reside |
35 | ; in a driver. |
35 | ; in a driver. |
36 | struct DISKFUNC |
36 | struct DISKFUNC |
37 | .strucsize dd ? |
37 | strucsize dd ? |
38 | ; Size of the structure. This field is intended for possible extensions of |
38 | ; Size of the structure. This field is intended for possible extensions of |
39 | ; this structure. If a new function is added to this structure and a driver |
39 | ; this structure. If a new function is added to this structure and a driver |
40 | ; implements an old version, the caller can detect this by checking .strucsize, |
40 | ; implements an old version, the caller can detect this by checking .strucsize, |
41 | ; so the driver remains compatible. |
41 | ; so the driver remains compatible. |
42 | .close dd ? |
42 | close dd ? |
43 | ; The pointer to the function which frees all driver-specific resources for |
43 | ; The pointer to the function which frees all driver-specific resources for |
44 | ; the disk. |
44 | ; the disk. |
45 | ; Optional, may be NULL. |
45 | ; Optional, may be NULL. |
46 | ; void close(void* userdata); |
46 | ; void close(void* userdata); |
47 | .closemedia dd ? |
47 | closemedia dd ? |
48 | ; The pointer to the function which informs the driver that the kernel has |
48 | ; The pointer to the function which informs the driver that the kernel has |
49 | ; finished all processing with the current media. If media is removed, the |
49 | ; finished all processing with the current media. If media is removed, the |
50 | ; driver should decline all requests to that media with DISK_STATUS_NO_MEDIA, |
50 | ; driver should decline all requests to that media with DISK_STATUS_NO_MEDIA, |
51 | ; even if new media is inserted, until this function is called. If media is |
51 | ; even if new media is inserted, until this function is called. If media is |
52 | ; removed, a new call to 'disk_media_changed' is not allowed until this |
52 | ; removed, a new call to 'disk_media_changed' is not allowed until this |
53 | ; function is called. |
53 | ; function is called. |
54 | ; Optional, may be NULL (if media is not removable). |
54 | ; Optional, may be NULL (if media is not removable). |
55 | ; void closemedia(void* userdata); |
55 | ; void closemedia(void* userdata); |
56 | .querymedia dd ? |
56 | querymedia dd ? |
57 | ; The pointer to the function which determines capabilities of the media. |
57 | ; The pointer to the function which determines capabilities of the media. |
58 | ; int querymedia(void* userdata, DISKMEDIAINFO* info); |
58 | ; int querymedia(void* userdata, DISKMEDIAINFO* info); |
59 | ; Return value: one of DISK_STATUS_* |
59 | ; Return value: one of DISK_STATUS_* |
60 | .read dd ? |
60 | read dd ? |
61 | ; The pointer to the function which reads data from the device. |
61 | ; The pointer to the function which reads data from the device. |
62 | ; int read(void* userdata, void* buffer, __int64 startsector, int* numsectors); |
62 | ; int read(void* userdata, void* buffer, __int64 startsector, int* numsectors); |
63 | ; input: *numsectors = number of sectors to read |
63 | ; input: *numsectors = number of sectors to read |
64 | ; output: *numsectors = number of sectors which were successfully read |
64 | ; output: *numsectors = number of sectors which were successfully read |
65 | ; Return value: one of DISK_STATUS_* |
65 | ; Return value: one of DISK_STATUS_* |
66 | .write dd ? |
66 | write dd ? |
67 | ; The pointer to the function which writes data to the device. |
67 | ; The pointer to the function which writes data to the device. |
68 | ; Optional, may be NULL. |
68 | ; Optional, may be NULL. |
69 | ; int write(void* userdata, void* buffer, __int64 startsector, int* numsectors); |
69 | ; int write(void* userdata, void* buffer, __int64 startsector, int* numsectors); |
70 | ; input: *numsectors = number of sectors to write |
70 | ; input: *numsectors = number of sectors to write |
71 | ; output: *numsectors = number of sectors which were successfully written |
71 | ; output: *numsectors = number of sectors which were successfully written |
72 | ; Return value: one of DISK_STATUS_* |
72 | ; Return value: one of DISK_STATUS_* |
73 | .flush dd ? |
73 | flush dd ? |
74 | ; The pointer to the function which flushes the internal device cache. |
74 | ; The pointer to the function which flushes the internal device cache. |
75 | ; Optional, may be NULL. |
75 | ; Optional, may be NULL. |
76 | ; int flush(void* userdata); |
76 | ; int flush(void* userdata); |
77 | ; Return value: one of DISK_STATUS_* |
77 | ; Return value: one of DISK_STATUS_* |
78 | ; Note that read/write are called by the cache manager, so a driver should not |
78 | ; Note that read/write are called by the cache manager, so a driver should not |
79 | ; create a software cache. This function is implemented for flushing a hardware |
79 | ; create a software cache. This function is implemented for flushing a hardware |
80 | ; cache, if it exists. |
80 | ; cache, if it exists. |
81 | .adjust_cache_size dd ? |
81 | adjust_cache_size dd ? |
82 | ; The pointer to the function which returns the cache size for this device. |
82 | ; The pointer to the function which returns the cache size for this device. |
83 | ; Optional, may be NULL. |
83 | ; Optional, may be NULL. |
84 | ; unsigned int adjust_cache_size(unsigned int suggested_size); |
84 | ; unsigned int adjust_cache_size(unsigned int suggested_size); |
85 | ; Return value: 0 = disable cache, otherwise = used cache size in bytes. |
85 | ; Return value: 0 = disable cache, otherwise = used cache size in bytes. |
86 | ends |
86 | ends |
Line 87... | Line 87... | ||
87 | 87 | ||
88 | ; This structure holds information on a medium. |
88 | ; This structure holds information on a medium. |
89 | ; Objects with this structure are allocated by the kernel as a part of the DISK |
89 | ; Objects with this structure are allocated by the kernel as a part of the DISK |
90 | ; structure and are filled by a driver in the 'querymedia' callback. |
90 | ; structure and are filled by a driver in the 'querymedia' callback. |
91 | struct DISKMEDIAINFO |
91 | struct DISKMEDIAINFO |
92 | .Flags dd ? |
92 | Flags dd ? |
93 | ; Combination of DISK_MEDIA_* bits. |
93 | ; Combination of DISK_MEDIA_* bits. |
94 | .SectorSize dd ? |
94 | SectorSize dd ? |
95 | ; Size of the sector. |
95 | ; Size of the sector. |
96 | .Capacity dq ? |
96 | Capacity dq ? |
97 | ; Size of the media in sectors. |
97 | ; Size of the media in sectors. |
Line 98... | Line 98... | ||
98 | ends |
98 | ends |
99 | 99 | ||
100 | ; This structure represents the disk cache. To follow the old implementation, |
100 | ; This structure represents the disk cache. To follow the old implementation, |
101 | ; there are two distinct caches for a disk, one for "system" data,and the other |
101 | ; there are two distinct caches for a disk, one for "system" data,and the other |
102 | ; for "application" data. |
102 | ; for "application" data. |
103 | struct DISKCACHE |
103 | struct DISKCACHE |
104 | .Lock MUTEX |
104 | mutex MUTEX |
105 | ; Lock to protect the cache. |
105 | ; Lock to protect the cache. |
106 | ; The following fields are inherited from data32.inc:cache_ideX. |
106 | ; The following fields are inherited from data32.inc:cache_ideX. |
107 | .pointer rd 1 |
107 | pointer dd ? |
108 | .data_size rd 1 ; not use |
108 | data_size dd ? ; unused |
109 | .data rd 1 |
109 | data dd ? |
110 | .sad_size rd 1 |
110 | sad_size dd ? |
Line 111... | Line 111... | ||
111 | .search_start rd 1 |
111 | search_start dd ? |
112 | ends |
112 | ends |
113 | 113 | ||
114 | ; This structure represents a disk device and its media for the kernel. |
114 | ; This structure represents a disk device and its media for the kernel. |
115 | ; This structure is allocated by the kernel in the 'disk_add' function, |
115 | ; This structure is allocated by the kernel in the 'disk_add' function, |
116 | ; freed in the 'disk_dereference' function. |
116 | ; freed in the 'disk_dereference' function. |
117 | struct DISK |
117 | struct DISK |
118 | ; Fields of disk object |
118 | ; Fields of disk object |
119 | .Next dd ? |
119 | Next dd ? |
120 | .Prev dd ? |
120 | Prev dd ? |
121 | ; All disk devices are linked in one list with these two fields. |
121 | ; All disk devices are linked in one list with these two fields. |
122 | ; Head of the list is the 'disk_list' variable. |
122 | ; Head of the list is the 'disk_list' variable. |
123 | .Functions dd ? |
123 | Functions dd ? |
124 | ; Pointer to the 'DISKFUNC' structure with driver functions. |
124 | ; Pointer to the 'DISKFUNC' structure with driver functions. |
125 | .Name dd ? |
125 | Name dd ? |
126 | ; Pointer to the string used for accesses through the global filesystem. |
126 | ; Pointer to the string used for accesses through the global filesystem. |
127 | .UserData dd ? |
127 | UserData dd ? |
128 | ; This field is passed to all callback functions so a driver can decide which |
128 | ; This field is passed to all callback functions so a driver can decide which |
129 | ; physical device is addressed. |
129 | ; physical device is addressed. |
130 | .DriverFlags dd ? |
130 | DriverFlags dd ? |
131 | ; Bitfield. Currently only DISK_NO_INSERT_NOTIFICATION bit is defined. |
131 | ; Bitfield. Currently only DISK_NO_INSERT_NOTIFICATION bit is defined. |
132 | ; If it is set, the driver will never issue 'disk_media_changed' notification |
132 | ; If it is set, the driver will never issue 'disk_media_changed' notification |
133 | ; with argument set to true, so the kernel must try to detect media during |
133 | ; with argument set to true, so the kernel must try to detect media during |
134 | ; requests from the file system. |
134 | ; requests from the file system. |
135 | .RefCount dd ? |
135 | RefCount dd ? |
136 | ; Count of active references to this structure. One reference is kept during |
136 | ; Count of active references to this structure. One reference is kept during |
137 | ; the lifetime of the structure between 'disk_add' and 'disk_del'. |
137 | ; the lifetime of the structure between 'disk_add' and 'disk_del'. |
138 | ; Another reference is taken during any filesystem operation for this disk. |
138 | ; Another reference is taken during any filesystem operation for this disk. |
139 | ; One reference is added if media is inserted. |
139 | ; One reference is added if media is inserted. |
140 | ; The structure is destroyed when the reference count decrements to zero: |
140 | ; The structure is destroyed when the reference count decrements to zero: |
141 | ; this usually occurs in 'disk_del', but can be delayed to the end of last |
141 | ; this usually occurs in 'disk_del', but can be delayed to the end of last |
142 | ; filesystem operation, if one is active. |
142 | ; filesystem operation, if one is active. |
143 | .MediaLock MUTEX |
143 | MediaLock MUTEX |
144 | ; Lock to protect the MEDIA structure. See the description after |
144 | ; Lock to protect the MEDIA structure. See the description after |
145 | ; 'disk_list_mutex' for the locking strategy. |
145 | ; 'disk_list_mutex' for the locking strategy. |
146 | ; Fields of media object |
146 | ; Fields of media object |
147 | .MediaInserted db ? |
147 | MediaInserted db ? |
148 | ; 0 if media is not inserted, nonzero otherwise. |
148 | ; 0 if media is not inserted, nonzero otherwise. |
149 | .MediaUsed db ? |
149 | MediaUsed db ? |
150 | ; 0 if media fields are not used, nonzero otherwise. If .MediaRefCount is |
150 | ; 0 if media fields are not used, nonzero otherwise. If .MediaRefCount is |
151 | ; nonzero, this field is nonzero too; however, when .MediaRefCount goes |
151 | ; nonzero, this field is nonzero too; however, when .MediaRefCount goes |
152 | ; to zero, there is some time interval during which media object is still used. |
152 | ; to zero, there is some time interval during which media object is still used. |
153 | align 4 |
153 | align 4 |
154 | ; The following fields are not valid unless either .MediaInserted is nonzero |
154 | ; The following fields are not valid unless either .MediaInserted is nonzero |
155 | ; or they are accessed from a code which has obtained the reference when |
155 | ; or they are accessed from a code which has obtained the reference when |
156 | ; .MediaInserted was nonzero. |
156 | ; .MediaInserted was nonzero. |
157 | .MediaRefCount dd ? |
157 | MediaRefCount dd ? |
158 | ; Count of active references to the media object. One reference is kept during |
158 | ; Count of active references to the media object. One reference is kept during |
159 | ; the lifetime of the media between two calls to 'disk_media_changed'. |
159 | ; the lifetime of the media between two calls to 'disk_media_changed'. |
160 | ; Another reference is taken during any filesystem operation for this media. |
160 | ; Another reference is taken during any filesystem operation for this media. |
161 | ; The callback 'closemedia' is called when the reference count decrements to |
161 | ; The callback 'closemedia' is called when the reference count decrements to |
162 | ; zero: this usually occurs in 'disk_media_changed', but can be delayed to the |
162 | ; zero: this usually occurs in 'disk_media_changed', but can be delayed to the |
163 | ; end of the last filesystem operation, if one is active. |
163 | ; end of the last filesystem operation, if one is active. |
164 | .MediaInfo DISKMEDIAINFO |
164 | MediaInfo DISKMEDIAINFO |
165 | ; This field keeps information on the current media. |
165 | ; This field keeps information on the current media. |
166 | .NumPartitions dd ? |
166 | NumPartitions dd ? |
167 | ; Number of partitions on this media. |
167 | ; Number of partitions on this media. |
168 | .Partitions dd ? |
168 | Partitions dd ? |
169 | ; Pointer to array of .NumPartitions pointers to PARTITION structures. |
169 | ; Pointer to array of .NumPartitions pointers to PARTITION structures. |
170 | .cache_size dd ? |
170 | cache_size dd ? |
171 | ; inherited from cache_ideX_size |
171 | ; inherited from cache_ideX_size |
172 | .SysCache DISKCACHE |
172 | SysCache DISKCACHE |
Line 173... | Line 173... | ||
173 | .AppCache DISKCACHE |
173 | AppCache DISKCACHE |
174 | ; Two caches for the disk. |
174 | ; Two caches for the disk. |
175 | ends |
175 | ends |
176 | 176 | ||
177 | ; This structure represents one partition for the kernel. This is a base |
177 | ; This structure represents one partition for the kernel. This is a base |
178 | ; template, the actual contents after common fields is determined by the |
178 | ; template, the actual contents after common fields is determined by the |
179 | ; file system code for this partition. |
179 | ; file system code for this partition. |
180 | struct PARTITION |
180 | struct PARTITION |
181 | .FirstSector dq ? |
181 | FirstSector dq ? |
182 | ; First sector of the partition. |
182 | ; First sector of the partition. |
183 | .Length dq ? |
183 | Length dq ? |
184 | ; Length of the partition in sectors. |
184 | ; Length of the partition in sectors. |
185 | .Disk dd ? |
185 | Disk dd ? |
186 | ; Pointer to parent DISK structure. |
186 | ; Pointer to parent DISK structure. |
187 | .FSUserFunctions dd ? |
187 | FSUserFunctions dd ? |
188 | ; Handlers for the sysfunction 70h. This field is a pointer to the following |
188 | ; Handlers for the sysfunction 70h. This field is a pointer to the following |
189 | ; array. The first dword is a number of supported subfunctions, other dwords |
189 | ; array. The first dword is a number of supported subfunctions, other dwords |
Line 190... | Line 190... | ||
190 | ; point to handlers of corresponding subfunctions. |
190 | ; point to handlers of corresponding subfunctions. |
191 | ; This field is 0 if file system is not recognized. |
191 | ; This field is 0 if file system is not recognized. |
192 | ; ...fs-specific data may follow... |
192 | ; ...fs-specific data may follow... |
193 | ends |
193 | ends |
194 | 194 | ||
195 | ; This is an external structure, it represents an entry in the partition table. |
195 | ; This is an external structure, it represents an entry in the partition table. |
196 | struct PARTITION_TABLE_ENTRY |
196 | struct PARTITION_TABLE_ENTRY |
197 | .Bootable db ? |
197 | Bootable db ? |
198 | ; 80h = bootable partition, 0 = non-bootable partition, other values = invalid |
198 | ; 80h = bootable partition, 0 = non-bootable partition, other values = invalid |
199 | .FirstHead db ? |
199 | FirstHead db ? |
200 | .FirstSector db ? |
200 | FirstSector db ? |
201 | .FirstTrack db ? |
201 | FirstTrack db ? |
202 | ; Coordinates of first sector in CHS. |
202 | ; Coordinates of first sector in CHS. |
203 | .Type db ? |
203 | Type db ? |
204 | ; Partition type, one of predefined constants. 0 = empty, several types denote |
204 | ; Partition type, one of predefined constants. 0 = empty, several types denote |
205 | ; extended partition (see process_partition_table_entry), we are not interested |
205 | ; extended partition (see process_partition_table_entry), we are not interested |
206 | ; in other values. |
206 | ; in other values. |
207 | .LastHead db ? |
207 | LastHead db ? |
208 | .LastSector db ? |
208 | LastSector db ? |
209 | .LastTrack db ? |
209 | LastTrack db ? |
210 | ; Coordinates of last sector in CHS. |
210 | ; Coordinates of last sector in CHS. |
Line 211... | Line 211... | ||
211 | .FirstAbsSector dd ? |
211 | FirstAbsSector dd ? |
212 | ; Coordinate of first sector in LBA. |
212 | ; Coordinate of first sector in LBA. |