Go to the source code of this file.
|
| constexpr int | kSectorCacheRowSize = 0x10000 |
| | The number of bytes each row buffers, which is what the row count divides the zone by.
|
| constexpr int | kSectorCacheFallbackSize = 0x80000 |
| | The space the cache assumes when zones are switched off.
|
| constexpr int | kSectorCacheRowEmpty = -1 |
| | Stored in a row's file and sector while the row buffers nothing.
|
| constexpr unsigned | kSectorCacheLocked = 0x99999999 |
| | Stamp that locks a row against reuse.
|
| constexpr unsigned | kSectorCacheStampCeiling = 0x7fffffff |
| | Stamp the least-recently-used search starts from, above every stamp the clock produces.
|
| constexpr unsigned | kSectorCacheStampHalfway = 0x3fffffff |
| | A chosen stamp above this triggers the rebase that stops the clock from wrapping.
|
| constexpr unsigned | kSectorCacheStampRebase = 0x40000000 |
| | The amount every stamp above the halfway mark is reduced by.
|
| SectorCache | gSectorCache |
| | The one sector cache.
|
◆ SectorCacheInit()
| void SectorCacheInit |
( |
int | nRows | ) |
|
Bring up the sector cache.
The cache takes the whole of the zone called seccache and divides it into as many kSectorCacheRowSize buffers as fit, so the requested row count applies only when zones are switched off. Every row starts empty. OpenArkObject::Open() is the caller, on the first mount, and it requests eight rows.
- Parameters
-
| nRows | The row count to use when zones are switched off. |
- Ghidra address:
- NTSC-U/C: 0x00554fb8
- Ghidra address:
- PAL: 0x00595640
◆ SectorCacheTerm()
Release every row and the row table.
A row buffer taken from a zone goes back through ZoneFree(), and one taken from the allocator goes back through MemFreeTagged().
- Ghidra address:
- NTSC-U/C: 0x005550c8
- Ghidra address:
- PAL: 0x00595750
◆ SectorCacheRemove()
| void SectorCacheRemove |
( |
int | nFile | ) |
|
Drop every row that buffers a file.
Each matching row has its file and sector reset to kSectorCacheRowEmpty and its stamp cleared, which makes it the oldest row and therefore the first to be reused. The buffers stay allocated.
- Parameters
-
| nFile | The file whose rows should be dropped. |
- Ghidra address:
- NTSC-U/C: 0x00555298
- Ghidra address:
- PAL: 0x00595920
◆ SectorCacheFind()
Find the row buffering a chunk.
A match that is not locked is stamped with the current clock, which makes it the newest row.
- Parameters
-
| nFile | The file. |
| nSector | The chunk index. |
- Returns
- The row, or null when no row buffers that chunk.
- Ghidra address:
- NTSC-U/C: 0x00555190
- Ghidra address:
- PAL: 0x00595818
◆ SectorCacheGetLRU()
Take the least recently used row for a chunk.
The name comes from the routine's own warning text. Locked rows are skipped. Once the chosen row's stamp passes the halfway mark every stamp is rebased downward, which is what stops the clock from wrapping. The row is then pointed at the requested chunk and stamped as newest, and its buffer still holds the previous chunk until a read replaces it.
- Parameters
-
| nFile | The file to buffer. |
| nSector | The chunk index to buffer. |
- Returns
- The row, or null when every row is locked.
- Ghidra address:
- NTSC-U/C: 0x00554e50
- Ghidra address:
- PAL: 0x005954d8
◆ SectorCacheLock()
| void SectorCacheLock |
( |
int | nFile, |
|
|
int | nSector ) |
Lock the row buffering a chunk against reuse.
The search repeats SectorCacheFind() inline, stamp bump included, and the chosen row then takes kSectorCacheLocked. A miss is reported through printf() and otherwise ignored. The image does not call this routine.
- Parameters
-
| nFile | The buffered file. |
| nSector | The buffered chunk index. |
- Ghidra address:
- NTSC-U/C: 0x005552f0
- Ghidra address:
- PAL: 0x00595978
◆ SetSectorRowLocked()
Lock one row against reuse.
The routine exists out of line because a caller in the asynchronous loader already has the row.
- Parameters
-
- Ghidra address:
- NTSC-U/C: 0x00555398
- Ghidra address:
- PAL: 0x00595a20
◆ UnlockCachedSector()
| void UnlockCachedSector |
( |
int | nFile, |
|
|
int | nSector ) |
Release the lock on the row buffering a chunk.
The search repeats SectorCacheFind() inline, whose stamp bump is skipped because a locked row stamp equals kSectorCacheLocked. Writing the current clock into the row both unlocks it and makes it the newest. A miss is reported through printf() and otherwise ignored.
- Parameters
-
| nFile | The buffered file. |
| nSector | The buffered chunk index. |
- Ghidra address:
- NTSC-U/C: 0x005553a8
- Ghidra address:
- PAL: 0x00595a30
◆ SectorCacheDump()
Print every row through printf().
- Ghidra address:
- NTSC-U/C: 0x005554a0
- Ghidra address:
- PAL: 0x00595b28
◆ kSectorCacheRowSize
| int kSectorCacheRowSize = 0x10000 |
|
constexpr |
The number of bytes each row buffers, which is what the row count divides the zone by.
◆ kSectorCacheFallbackSize
| int kSectorCacheFallbackSize = 0x80000 |
|
constexpr |
The space the cache assumes when zones are switched off.
◆ kSectorCacheRowEmpty
| int kSectorCacheRowEmpty = -1 |
|
constexpr |
Stored in a row's file and sector while the row buffers nothing.
◆ kSectorCacheLocked
| unsigned kSectorCacheLocked = 0x99999999 |
|
constexpr |
Stamp that locks a row against reuse.
SectorCacheGetLRU() skips a locked row, and neither routine advances a locked row's stamp. The value sorts above every real stamp, so the unsigned comparison in the search excludes it even before the explicit test.
◆ kSectorCacheStampCeiling
| unsigned kSectorCacheStampCeiling = 0x7fffffff |
|
constexpr |
Stamp the least-recently-used search starts from, above every stamp the clock produces.
◆ kSectorCacheStampHalfway
| unsigned kSectorCacheStampHalfway = 0x3fffffff |
|
constexpr |
A chosen stamp above this triggers the rebase that stops the clock from wrapping.
◆ kSectorCacheStampRebase
| unsigned kSectorCacheStampRebase = 0x40000000 |
|
constexpr |
The amount every stamp above the halfway mark is reduced by.
◆ gSectorCache
The one sector cache.
- Ghidra address:
- NTSC-U/C: 0x008de790
- Ghidra address:
- PAL: 0x00923750