39 lines
807 B
C
39 lines
807 B
C
#ifndef SEGMENTS_FILE_H
|
|
#define SEGMENTS_FILE_H
|
|
|
|
#include "mmu.h"
|
|
#include "../common/platform.h"
|
|
|
|
//enable caching on PC only, as the file module already caches on casio
|
|
#if defined(PC)
|
|
#define CACHE_LEN 1024
|
|
#endif
|
|
|
|
typedef struct file_segment_t {
|
|
int fd;
|
|
#if defined(PC)
|
|
int cacheOff;
|
|
int cacheLen;
|
|
#endif
|
|
int filePos;
|
|
int fileSize;
|
|
char access;
|
|
#if defined(PC)
|
|
char cacheWritten;
|
|
char cache[CACHE_LEN];
|
|
#endif
|
|
} file_segment_t;
|
|
|
|
void fileSegmentInit(file_segment_t *segment, int fd, int pos, int len, char access);
|
|
|
|
void fileSegmentRead(int pos, char* value, void *segment);
|
|
void fileSegmentWrite(int pos, char value, void *segment);
|
|
|
|
//don't cache on casio
|
|
#if defined(PC)
|
|
int fileSegmentFlush(file_segment_t *segment);
|
|
int fileSegmentLoad(file_segment_t *segment, int pos);
|
|
#endif
|
|
|
|
#endif
|