Commit 701fd1ff authored by alex@thinkpad's avatar alex@thinkpad
Browse files

fio-ml: FIO_WriteFile wrapper to handle caching issues automatically

sed -i.bak '/ FIO_WriteFile/_FIO_WriteFile/' */stubs.S

--HG--
branch : cache-fixes
parent 91c1213a2f6c
......@@ -46,7 +46,7 @@ NSTUB(0xFF1DA5F0, FIO_FindClose) // might be good (du
NSTUB(0xFF1DA510, FIO_FindNextEx) // might be good (dumps=1, score=50)
NSTUB(0xFF1D93D0, FIO_ReadFile) // might be good (dumps=1, score=87)
NSTUB(0xFF1D9480, FIO_SeekSkipFile) /* present on 5D3.113, EOSM.202 */
NSTUB(0xFF1D9570, FIO_WriteFile) // might be good (dumps=1, score=65)
NSTUB(0xFF1D9570, _FIO_WriteFile) // might be good (dumps=1, score=65)
NSTUB(0xFF1D9E5C, _FIO_CreateDirectory) // might be good (dumps=1, score=13)
NSTUB(0xFF1D927C, _FIO_CreateFile) // might be good (dumps=1, score=50)
NSTUB(0xFF1DA41C, _FIO_FindFirstEx) // might be good (dumps=1, score=50)
......
......@@ -50,7 +50,7 @@ NSTUB(0xFF1975A4, FIO_FindClose) // called with ret_F
NSTUB(0xFF1974A4, FIO_FindNextEx)
NSTUB(0xFF196724, FIO_ReadFile)
NSTUB(0xFF1967D4, FIO_SeekSkipFile)
NSTUB(0xFF1968D4, FIO_WriteFile)
NSTUB(0xFF1968D4, _FIO_WriteFile)
NSTUB(0xFF196CF8, _FIO_CreateDirectory)
NSTUB(0xFF1963EC, _FIO_CreateFile)
NSTUB(0xFF197378, _FIO_FindFirstEx)
......
......@@ -55,7 +55,7 @@ NSTUB(0xFF9836A0, FIO_FindClose) // called with ret_F
NSTUB(0xFF9835A0, FIO_FindNextEx) // d
NSTUB(0xFF982820, FIO_ReadFile) // d
NSTUB(0xFF9828D0, FIO_SeekSkipFile)
NSTUB(0xFF9829D0, FIO_WriteFile) // d
NSTUB(0xFF9829D0, _FIO_WriteFile) // d
NSTUB(0xFF982DF4, _FIO_CreateDirectory)
NSTUB(0xFF9824E8, _FIO_CreateFile) // d
NSTUB(0xFF983474, _FIO_FindFirstEx) // d
......
......@@ -55,7 +55,7 @@ NSTUB(0xFF1C7934, FIO_FindClose) // called with ret_F
NSTUB(0xFF1C7854, FIO_FindNextEx)
NSTUB(0xFF1C679C, FIO_ReadFile)
NSTUB(0xFF1C684C, FIO_SeekSkipFile)
NSTUB(0xFF1C693C, FIO_WriteFile)
NSTUB(0xFF1C693C, _FIO_WriteFile)
NSTUB(0xFF1C71A0, _FIO_CreateDirectory)
NSTUB(0xFF1C6648, _FIO_CreateFile)
NSTUB(0xFF1C7760, _FIO_FindFirstEx)
......
......@@ -46,7 +46,7 @@ NSTUB(0xFF9ABE20, FIO_FindClose)
NSTUB(0xFF9ABD20, FIO_FindNextEx)
NSTUB(0xFF9AAFA0, FIO_ReadFile)
NSTUB(0xFF9AB050, FIO_SeekSkipFile)
NSTUB(0xFF9AB150, FIO_WriteFile)
NSTUB(0xFF9AB150, _FIO_WriteFile)
NSTUB(0xFF9AB574, _FIO_CreateDirectory)
NSTUB(0xFF9AAC68, _FIO_CreateFile)
NSTUB(0xFF9ABBF4, _FIO_FindFirstEx)
......
......@@ -46,7 +46,7 @@ NSTUB(0xFF30AD30, FIO_FindClose) // proper name: Find
NSTUB(0xFF30AC50, FIO_FindNextEx)
NSTUB(0xFF309AE8, FIO_ReadFile)
NSTUB(0xFF309B98, FIO_SeekSkipFile)
NSTUB(0xFF309C88, FIO_WriteFile)
NSTUB(0xFF309C88, _FIO_WriteFile)
NSTUB(0xFF30A594, _FIO_CreateDirectory)
NSTUB(0xFF309994, _FIO_CreateFile)
NSTUB(0xFF30AB5C, _FIO_FindFirstEx)
......
......@@ -60,7 +60,7 @@ NSTUB(0xFF30F80C, FIO_FindClose) // proper name: Find
NSTUB(0xFF30F72C, FIO_FindNextEx)
NSTUB(0xFF30E5C4, FIO_ReadFile)
NSTUB(0xFF30E674, FIO_SeekSkipFile)
NSTUB(0xFF30E764, FIO_WriteFile)
NSTUB(0xFF30E764, _FIO_WriteFile)
NSTUB(0xFF30F070, _FIO_CreateDirectory)
NSTUB(0xFF30E470, _FIO_CreateFile)
NSTUB(0xFF30F638, _FIO_FindFirstEx)
......
......@@ -64,7 +64,7 @@ NSTUB(0xFF1E7684, FIO_FindClose) // called with ret_F
NSTUB(0xFF1E75A4, FIO_FindNextEx)
NSTUB(0xFF1E6464, FIO_ReadFile)
NSTUB(0xFF1E6514, FIO_SeekSkipFile)
NSTUB(0xFF1E6604, FIO_WriteFile)
NSTUB(0xFF1E6604, _FIO_WriteFile)
NSTUB(0xFF1E6EF0, _FIO_CreateDirectory)
NSTUB(0xFF1E6310, _FIO_CreateFile)
NSTUB(0xFF1E74B0, _FIO_FindFirstEx)
......
......@@ -53,7 +53,7 @@ NSTUB(0xFF1CB3CC, FIO_FindClose) // called with ret_F
NSTUB(0xFF1CB2EC, FIO_FindNextEx)
NSTUB(0xFF1CA1AC, FIO_ReadFile)
NSTUB(0xFF1CA25C, FIO_SeekSkipFile) /* present on 5D3.113, EOSM.202 */
NSTUB(0xFF1CA34C, FIO_WriteFile)
NSTUB(0xFF1CA34C, _FIO_WriteFile)
NSTUB(0xFF1CAC38, _FIO_CreateDirectory)
NSTUB(0xFF1CA058, _FIO_CreateFile)
NSTUB(0xFF1CB1F8, _FIO_FindFirstEx)
......
......@@ -50,7 +50,7 @@ NSTUB(0xFF343904, FIO_FindClose) // proper name: Find
NSTUB(0xFF343824, FIO_FindNextEx)
NSTUB(0xFF3426BC, FIO_ReadFile)
NSTUB(0xFF34276C, FIO_SeekSkipFile) /* took relative offset of 700D entry points and compared them to 650Ds. Tests are OK. */
NSTUB(0xFF34285C, FIO_WriteFile) // from Indy
NSTUB(0xFF34285C, _FIO_WriteFile) // from Indy
NSTUB(0xFF343168, _FIO_CreateDirectory)
NSTUB(0xFF342568, _FIO_CreateFile) // from Indy
NSTUB(0xFF343730, _FIO_FindFirstEx)
......
......@@ -50,7 +50,7 @@ NSTUB(0xFF333974, FIO_FindClose) // proper name: Find
NSTUB(0xFF333894, FIO_FindNextEx)
NSTUB(0xFF33272C, FIO_ReadFile)
NSTUB(0xFF3327DC, FIO_SeekSkipFile)
NSTUB(0xFF3328CC, FIO_WriteFile)
NSTUB(0xFF3328CC, _FIO_WriteFile)
NSTUB(0xFF3331D8, _FIO_CreateDirectory)
NSTUB(0xFF3325D8, _FIO_CreateFile)
NSTUB(0xFF3337A0, _FIO_FindFirstEx)
......
......@@ -49,7 +49,7 @@ NSTUB(0xFF346454, FIO_FindClose) // FindClose
NSTUB(0xFF346374, FIO_FindNextEx)
NSTUB(0xFF34520C, FIO_ReadFile)
NSTUB(0xFF3452BC, FIO_SeekSkipFile)
NSTUB(0xFF3453AC, FIO_WriteFile)
NSTUB(0xFF3453AC, _FIO_WriteFile)
NSTUB(0xFF345CB8, _FIO_CreateDirectory)
NSTUB(0xFF3450B8, _FIO_CreateFile)
NSTUB(0xFF346280, _FIO_FindFirstEx)
......
......@@ -47,7 +47,7 @@ NSTUB(0xFF1FD554, FIO_FindClose) // AJ__switch_0x1A50
NSTUB(0xFF1FD42C, FIO_FindNextEx)
NSTUB(0xFF1FC434, FIO_ReadFile)
NSTUB(0xFF1FC4E4, FIO_SeekSkipFile)
NSTUB(0xFF1FC5D4, FIO_WriteFile)
NSTUB(0xFF1FC5D4, _FIO_WriteFile)
NSTUB(0xFF1FCCF4, _FIO_CreateDirectory) // not sure. g3gg0: confirmed by caller 'ctgDirCreate'
NSTUB(0xFF1FC2E0, _FIO_CreateFile)
NSTUB(0xFF1FD2B8, _FIO_FindFirstEx)
......
......@@ -44,7 +44,7 @@ NSTUB(0xFF812B4C, init_task)
// NSTUB( ???, FIO_FindNextEx) /* present on 7D.203, 500D.111, 60D.111, 6D.113, 5D3.113, 50D.109, 5D2.212, 600D.102, 650D.104, 550D.109, 1100D.105, EOSM.202, 700D.113 */
// NSTUB( ???, FIO_ReadFile) /* present on 7D.203, 500D.111, 60D.111, 6D.113, 5D3.113, 50D.109, 5D2.212, 600D.102, 650D.104, 550D.109, 1100D.105, EOSM.202, 700D.113 */
// NSTUB( ???, FIO_SeekSkipFile) /* present on 5D3.113, EOSM.202 */
// NSTUB( ???, FIO_WriteFile) /* present on 7D.203, 500D.111, 60D.111, 6D.113, 5D3.113, 50D.109, 5D2.212, 600D.102, 650D.104, 550D.109, 1100D.105, EOSM.202, 700D.113 */
// NSTUB( ???, _FIO_WriteFile) /* present on 7D.203, 500D.111, 60D.111, 6D.113, 5D3.113, 50D.109, 5D2.212, 600D.102, 650D.104, 550D.109, 1100D.105, EOSM.202, 700D.113 */
// NSTUB( ???, _FIO_CreateDirectory) /* present on 7D.203, 500D.111, 60D.111, 6D.113, 5D3.113, 50D.109, 5D2.212, 600D.102, 650D.104, 550D.109, 1100D.105, EOSM.202, 700D.113 */
// NSTUB( ???, _FIO_CreateFile) /* present on 7D.203, 500D.111, 60D.111, 6D.113, 5D3.113, 50D.109, 5D2.212, 600D.102, 650D.104, 550D.109, 1100D.105, EOSM.202, 700D.113 */
// NSTUB( ???, _FIO_FindFirstEx) /* present on 7D.203, 500D.111, 60D.111, 6D.113, 5D3.113, 50D.109, 5D2.212, 600D.102, 650D.104, 550D.109, 1100D.105, EOSM.202, 700D.113 */
......
......@@ -46,7 +46,7 @@ NSTUB(0xFF3478EC, FIO_FindClose) // proper name: Find
NSTUB(0xFF34780C, FIO_FindNextEx)
NSTUB(0xFF3466A4, FIO_ReadFile)
NSTUB(0xFF346754, FIO_SeekSkipFile)
NSTUB(0xFF346844, FIO_WriteFile)
NSTUB(0xFF346844, _FIO_WriteFile)
NSTUB(0xFF347150, _FIO_CreateDirectory)
NSTUB(0xFF346550, _FIO_CreateFile)
NSTUB(0xFF347718, _FIO_FindFirstEx)
......
......@@ -497,6 +497,7 @@ static FILE* _FIO_CreateFileEx(const char* name)
/* return 0 on error, just like in plain C */
return 0;
}
FILE* FIO_CreateFile(const char* name)
{
char new_name[FIO_MAX_PATH_LENGTH];
......@@ -504,6 +505,26 @@ FILE* FIO_CreateFile(const char* name)
return _FIO_CreateFileEx(new_name);
}
/* Canon stub */
extern int _FIO_WriteFile( FILE* stream, const void* ptr, size_t count );
int FIO_WriteFile( FILE* stream, const void* ptr, size_t count )
{
/* we often assumed that the FIO routines will somehow care for buffers being still in cache.
proven by the fact that even canon calls FIO_WriteFile with cached memory as source.
that was simply incorrect. force cache flush if the buffer is a cachable one.
*/
if (ptr == CACHEABLE(ptr))
{
/* write back all data to RAM */
/* todo: check performance penalty
* is it worth cleaning only the current buffer? */
clean_d_cache();
}
return _FIO_WriteFile(stream, ptr, count);
}
FILE* FIO_CreateFileOrAppend(const char* name)
{
/* credits: https://bitbucket.org/dmilligan/magic-lantern/commits/d7e0245b1c62c26231799e9be3b54dd77d51a283 */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment