KolibriOS kernel
disk_cache.inc File Reference

Classes

struct  CACHE_ITEM
 This structure describes one item in the cache. More...
 

Functions

void cache_lookup_read ()
 Lookup for the given sector in the given cache. If the sector is not present, return error. The caller must acquire the cache lock. in: edx:eax = sector in: ebx -> DISKCACHE structure out: CF set if sector is not in cache out: ecx = sector_size_log out: esi -> sector:status out: edi -> sector data. More...
 
void cache_lookup_write ()
 Lookup for the given sector in the given cache. If the sector is not present, allocate space for it, possibly flushing data. in: edx:eax = sector in: ebx -> DISKCACHE structure in: ebp -> PARTITION structure out: eax = error code out: esi -> sector:status out: edi -> sector data. More...
 
void write_cache64 ()
 Flush the given cache. The caller must acquire the cache lock. in: ebx -> DISKCACHE in: first argument in stdcall convention -> PARTITION. More...
 

Variables

label fs_read64_sys
 Read several sequential sectors using cache #1. in: edx:eax = start sector, relative to start of partition in: ecx = number of sectors to read in: ebx -> buffer in: ebp -> PARTITION out: eax = error code, 0 = ok out: ecx = number of sectors that were read. More...
 
label fs_read64_app
 Read several sequential sectors using cache #2. in: edx:eax = start sector, relative to start of partition in: ecx = number of sectors to read in: ebx -> buffer in: ebp -> PARTITION out: eax = error code, 0 = ok out: ecx = number of sectors that were read. More...
 
label fs_read64_common
 Common part of fs_read64_{app,sys}: read several sequential sectors using the given cache. More...
 
dd _num_sectors_orig
 
dd _num_sectors
 Number of sectors that should be read. Used to generate output value of ecx. More...
 
dd _sector_lo
 Number of sectors that remain to be read. Decreases from .num_sectors_orig to 0. low 32 bits of the current sector. More...
 
dd _sector_hi
 high 32 bits of the current sector More...
 
dd _cache
 pointer to DISKCACHE More...
 
dd _error_code
 current status More...
 
rd _saved_regs
 
dd _buffer
 filled by fs_read64_{sys,app} More...
 
dd _current_num_sectors
 number of sectors that were read More...
 
dd _current_buffer
 pointer to data that are currently copying More...
 
dd _allocated_buffer
 pointer inside .allocated_buffer that points to the beginning of not-processed data saved in safe place More...
 
dd _iteration_size
 saved in safe place More...
 
label fs_write64_sys
 Write several sequential sectors using cache #1. in: edx:eax = start sector in: ecx = number of sectors to write in: ebx -> buffer in: ebp -> PARTITION out: eax = error code, 0 = ok out: ecx = number of sectors that were written. More...
 
label fs_write64_app
 Write several sequential sectors using cache #2. in: edx:eax = start sector in: ecx = number of sectors to write in: ebx -> buffer in: ebp -> PARTITION out: eax = error code, 0 = ok out: ecx = number of sectors that were written. More...
 
label fs_write64_common
 Common part of fs_write64_{app,sys}: write several sequential sectors using the given cache. More...
 
dd _cur_buffer
 pointer to data that are currently copying More...
 
label fs_read32_sys
 Legacy. Use fs_read64_sys instead. This function is intended to replace the old 'hd_read' function when [hdd_appl_data] = 0, so its input/output parameters are the same, except that it can't use the global variables 'hd_error' and 'hdd_appl_data'. in: eax = sector, ebx = buffer, ebp = pointer to PARTITION structure eax is relative to partition start out: eax = error code; 0 = ok. More...
 
label fs_read32_app
 Legacy. Use fs_read64_app instead. This function is intended to replace the old 'hd_read' function when [hdd_appl_data] = 1, so its input/output parameters are the same, except that it can't use the global variables 'hd_error' and 'hdd_appl_data'. in: eax = sector, ebx = buffer, ebp = pointer to PARTITION structure eax is relative to partition start out: eax = error code; 0 = ok. More...
 
label fs_read32_common
 This label is the common part of fs_read32_sys and fs_read32_app. More...
 
label fs_write32_sys
 This function is intended to replace the old 'hd_write' function when [hdd_appl_data] = 0, so its input/output parameters are the same, except that it can't use the global variables 'hd_error' and 'hdd_appl_data'. in: eax = sector, ebx = buffer, ebp = pointer to PARTITION structure eax is relative to partition start out: eax = error code; 0 = ok. More...
 
label fs_write32_app
 This function is intended to replace the old 'hd_write' function when [hdd_appl_data] = 1, so its input/output parameters are the same, except that it can't use the global variables 'hd_error' and 'hdd_appl_data'. in: eax = sector, ebx = buffer, ebp = pointer to PARTITION structure eax is relative to partition start out: eax = error code; 0 = ok. More...
 
dd _cache_end
 item past the end of the cache More...
 
dd _size_left
 items left to scan More...
 
dd _current_ptr
 pointer to the current item More...
 
dd _sequential
 Write operations are coalesced in chains, one chain describes a sequential interval of sectors, they can be sequential or scattered in the cache. More...
 
dd _chain_start_pos
 boolean variable, 1 if the current chain is sequential in the cache, 0 if additional buffer is needed to perform the operation data of chain start item More...
 
dd _chain_start_ptr
 pointer to chain start item More...
 
dd _chain_size
 chain size (thanks, C.O.) More...
 
dd _iteration_buffer
 If the chain size is too large, split the operation to several iterations. This is size in sectors for one iterations. temporary buffer for non-sequential chains. More...
 
dd _disk
 first argument More...
 
label disk_init_cache
 This internal function is called from disk_add to initialize the caching for a new DISK. The algorithm is inherited from getcache.inc: take 1/32 part of the available physical memory, round down to 8 pages, limit by 128K from below and by 1M from above. Reserve 1/8 part of the cache for system data and 7/8 for app data. After the size is calculated, but before the cache is allocated, the device driver can adjust the size. In particular, setting size to zero disables caching: there is no sense in a cache for a ramdisk. In fact, such action is most useful example of a non-trivial adjustment. esi = pointer to DISK structure. More...
 
label calculate_cache_slots
 
label disk_free_cache
 This internal function is called from disk_media_dereference to free the allocated cache, if there is one. esi = pointer to DISK structure. More...
 
label disk_sync
 This function flushes all modified data from both caches for the given DISK. esi = pointer to DISK. More...
 

Function Documentation

◆ cache_lookup_read()

void cache_lookup_read ( )

Lookup for the given sector in the given cache. If the sector is not present, return error. The caller must acquire the cache lock. in: edx:eax = sector in: ebx -> DISKCACHE structure out: CF set if sector is not in cache out: ecx = sector_size_log out: esi -> sector:status out: edi -> sector data.

Source
blkdev/disk_cache.inc:811

◆ cache_lookup_write()

void cache_lookup_write ( )

Lookup for the given sector in the given cache. If the sector is not present, allocate space for it, possibly flushing data. in: edx:eax = sector in: ebx -> DISKCACHE structure in: ebp -> PARTITION structure out: eax = error code out: esi -> sector:status out: edi -> sector data.

Source
blkdev/disk_cache.inc:851

◆ write_cache64()

void write_cache64 ( )

Flush the given cache. The caller must acquire the cache lock. in: ebx -> DISKCACHE in: first argument in stdcall convention -> PARTITION.

Source
blkdev/disk_cache.inc:907

Variable Documentation

◆ _allocated_buffer

dd _allocated_buffer

pointer inside .allocated_buffer that points to the beginning of not-processed data saved in safe place

saved at safe place

Initial value
?
Source
blkdev/disk_cache.inc:222
Initial value
?
Source
blkdev/disk_cache.inc:651

◆ _buffer

dd _buffer

filled by fs_read64_{sys,app}

filled by fs_write64_{sys,app}

Initial value
?
Source
blkdev/disk_cache.inc:88
Initial value
?
Source
blkdev/disk_cache.inc:400
Initial value
?
Source
blkdev/disk_cache.inc:585

◆ _cache

dd _cache

pointer to DISKCACHE

Initial value
?
Source
blkdev/disk_cache.inc:84
Initial value
?
Source
blkdev/disk_cache.inc:582

◆ _cache_end

dd _cache_end

item past the end of the cache

Initial value
?
Source
blkdev/disk_cache.inc:913

◆ _chain_size

dd _chain_size

chain size (thanks, C.O.)

Initial value
?
Source
blkdev/disk_cache.inc:925

◆ _chain_start_pos

dd _chain_start_pos

boolean variable, 1 if the current chain is sequential in the cache, 0 if additional buffer is needed to perform the operation data of chain start item

Initial value
?
Source
blkdev/disk_cache.inc:923

◆ _chain_start_ptr

dd _chain_start_ptr

pointer to chain start item

Initial value
?
Source
blkdev/disk_cache.inc:924

◆ _cur_buffer

dd _cur_buffer

pointer to data that are currently copying

Initial value
?
Source
blkdev/disk_cache.inc:390

◆ _current_buffer

dd _current_buffer

pointer to data that are currently copying

Initial value
?
Source
blkdev/disk_cache.inc:219
Initial value
?
Source
blkdev/disk_cache.inc:650

◆ _current_num_sectors

dd _current_num_sectors

number of sectors that were read

Initial value
?
Source
blkdev/disk_cache.inc:218

◆ _current_ptr

dd _current_ptr

pointer to the current item

Initial value
?
Source
blkdev/disk_cache.inc:915

◆ _disk

dd _disk

first argument

Initial value
?
Source
blkdev/disk_cache.inc:933

◆ _error_code

dd _error_code

current status

Initial value
?
Source
blkdev/disk_cache.inc:85
Initial value
?
Source
blkdev/disk_cache.inc:397

◆ _iteration_buffer

dd _iteration_buffer

If the chain size is too large, split the operation to several iterations. This is size in sectors for one iterations. temporary buffer for non-sequential chains.

Initial value
?
Source
blkdev/disk_cache.inc:929

◆ _iteration_size

dd _iteration_size

saved in safe place

Initial value
?
Source
blkdev/disk_cache.inc:223
Initial value
?
Source
blkdev/disk_cache.inc:926

◆ _num_sectors

dd _num_sectors

Number of sectors that should be read. Used to generate output value of ecx.

number of sectors left

Number of sectors that should be written. Used to generate output value of ecx.

Initial value
?
Source
blkdev/disk_cache.inc:80
Initial value
?
Source
blkdev/disk_cache.inc:393
Initial value
?
Source
blkdev/disk_cache.inc:649

◆ _num_sectors_orig

dd _num_sectors_orig
Initial value
?
Source
blkdev/disk_cache.inc:78
Initial value
?
Source
blkdev/disk_cache.inc:391

◆ _saved_regs

rd _saved_regs
Initial value
2
Source
blkdev/disk_cache.inc:87
Initial value
2
Source
blkdev/disk_cache.inc:399
Initial value
4
Source
blkdev/disk_cache.inc:584

◆ _sector_hi

dd _sector_hi

high 32 bits of the current sector

Initial value
?
Source
blkdev/disk_cache.inc:83
Initial value
?
Source
blkdev/disk_cache.inc:396
Initial value
?
Source
blkdev/disk_cache.inc:581

◆ _sector_lo

dd _sector_lo

Number of sectors that remain to be read. Decreases from .num_sectors_orig to 0. low 32 bits of the current sector.

Number of sectors that remain to be written. low 32 bits of the current sector.

Initial value
?
Source
blkdev/disk_cache.inc:82
Initial value
?
Source
blkdev/disk_cache.inc:395
Initial value
?
Source
blkdev/disk_cache.inc:580

◆ _sequential

dd _sequential

Write operations are coalesced in chains, one chain describes a sequential interval of sectors, they can be sequential or scattered in the cache.

Initial value
?
Source
blkdev/disk_cache.inc:920

◆ _size_left

dd _size_left

items left to scan

Initial value
?
Source
blkdev/disk_cache.inc:914

◆ calculate_cache_slots

label calculate_cache_slots

◆ disk_free_cache

label disk_free_cache

This internal function is called from disk_media_dereference to free the allocated cache, if there is one. esi = pointer to DISK structure.

Source
blkdev/disk_cache.inc:1356

◆ disk_init_cache

label disk_init_cache

This internal function is called from disk_add to initialize the caching for a new DISK. The algorithm is inherited from getcache.inc: take 1/32 part of the available physical memory, round down to 8 pages, limit by 128K from below and by 1M from above. Reserve 1/8 part of the cache for system data and 7/8 for app data. After the size is calculated, but before the cache is allocated, the device driver can adjust the size. In particular, setting size to zero disables caching: there is no sense in a cache for a ramdisk. In fact, such action is most useful example of a non-trivial adjustment. esi = pointer to DISK structure.

Source
blkdev/disk_cache.inc:1232

◆ disk_sync

label disk_sync

This function flushes all modified data from both caches for the given DISK. esi = pointer to DISK.

Source
blkdev/disk_cache.inc:1367

◆ fs_read32_app

label fs_read32_app

Legacy. Use fs_read64_app instead. This function is intended to replace the old 'hd_read' function when [hdd_appl_data] = 1, so its input/output parameters are the same, except that it can't use the global variables 'hd_error' and 'hdd_appl_data'. in: eax = sector, ebx = buffer, ebp = pointer to PARTITION structure eax is relative to partition start out: eax = error code; 0 = ok.

Source
blkdev/disk_cache.inc:538

◆ fs_read32_common

label fs_read32_common

This label is the common part of fs_read32_sys and fs_read32_app.

Source
blkdev/disk_cache.inc:545

◆ fs_read32_sys

label fs_read32_sys

Legacy. Use fs_read64_sys instead. This function is intended to replace the old 'hd_read' function when [hdd_appl_data] = 0, so its input/output parameters are the same, except that it can't use the global variables 'hd_error' and 'hdd_appl_data'. in: eax = sector, ebx = buffer, ebp = pointer to PARTITION structure eax is relative to partition start out: eax = error code; 0 = ok.

Source
blkdev/disk_cache.inc:524

◆ fs_read64_app

label fs_read64_app

Read several sequential sectors using cache #2. in: edx:eax = start sector, relative to start of partition in: ecx = number of sectors to read in: ebx -> buffer in: ebp -> PARTITION out: eax = error code, 0 = ok out: ecx = number of sectors that were read.

Source
blkdev/disk_cache.inc:63

◆ fs_read64_common

label fs_read64_common

Common part of fs_read64_{app,sys}: read several sequential sectors using the given cache.

Source
blkdev/disk_cache.inc:71

◆ fs_read64_sys

label fs_read64_sys

Read several sequential sectors using cache #1. in: edx:eax = start sector, relative to start of partition in: ecx = number of sectors to read in: ebx -> buffer in: ebp -> PARTITION out: eax = error code, 0 = ok out: ecx = number of sectors that were read.

Source
blkdev/disk_cache.inc:49

◆ fs_write32_app

label fs_write32_app

This function is intended to replace the old 'hd_write' function when [hdd_appl_data] = 1, so its input/output parameters are the same, except that it can't use the global variables 'hd_error' and 'hdd_appl_data'. in: eax = sector, ebx = buffer, ebp = pointer to PARTITION structure eax is relative to partition start out: eax = error code; 0 = ok.

Source
blkdev/disk_cache.inc:793

◆ fs_write32_sys

label fs_write32_sys

This function is intended to replace the old 'hd_write' function when [hdd_appl_data] = 0, so its input/output parameters are the same, except that it can't use the global variables 'hd_error' and 'hdd_appl_data'. in: eax = sector, ebx = buffer, ebp = pointer to PARTITION structure eax is relative to partition start out: eax = error code; 0 = ok.

Source
blkdev/disk_cache.inc:778

◆ fs_write64_app

label fs_write64_app

Write several sequential sectors using cache #2. in: edx:eax = start sector in: ecx = number of sectors to write in: ebx -> buffer in: ebp -> PARTITION out: eax = error code, 0 = ok out: ecx = number of sectors that were written.

Source
blkdev/disk_cache.inc:373

◆ fs_write64_common

label fs_write64_common

Common part of fs_write64_{app,sys}: write several sequential sectors using the given cache.

Source
blkdev/disk_cache.inc:381

◆ fs_write64_sys

label fs_write64_sys

Write several sequential sectors using cache #1. in: edx:eax = start sector in: ecx = number of sectors to write in: ebx -> buffer in: ebp -> PARTITION out: eax = error code, 0 = ok out: ecx = number of sectors that were written.

Source
blkdev/disk_cache.inc:359