Skip to content

Commit

Permalink
readahead: define config macro and osbdev func
Browse files Browse the repository at this point in the history
For context, see issue #16 in the Reliance Edge repository on GitHub.
  • Loading branch information
danielrlewis committed Jan 12, 2021
1 parent 75b1efb commit e66ade5
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/redconfigchk.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,15 @@
#error "Configuration error: REDCONF_CHECKER must be defined."
#endif

/* For the prototype, REDCONF_READAHEAD hasn't been added to all the redconf.h
files; assume it is disabled if undefined.
*/
#ifndef REDCONF_READAHEAD
#define REDCONF_READAHEAD 0
#elif (REDCONF_READAHEAD != 0) && (REDCONF_READAHEAD != 1)
#error "Configuration error: REDCONF_READAHEAD must be either 0 or 1."
#endif

#if (REDCONF_READ_ONLY != 0) && (REDCONF_READ_ONLY != 1)
#error "Configuration error: REDCONF_READ_ONLY must be either 0 or 1"
#endif
Expand Down
3 changes: 3 additions & 0 deletions include/redosserv.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ REDSTATUS RedOsBDevOpen(uint8_t bVolNum, BDEVOPENMODE mode);
REDSTATUS RedOsBDevGetGeometry(uint8_t bVolNum, BDEVINFO *pInfo);
REDSTATUS RedOsBDevClose(uint8_t bVolNum);
REDSTATUS RedOsBDevRead(uint8_t bVolNum, uint64_t ullSectorStart, uint32_t ulSectorCount, void *pBuffer);
#if REDCONF_READAHEAD == 1
void RedOsBDevReadahead(uint8_t bVolNum, uint64_t ullSectorStart, uint32_t ulSectorCount);
#endif

#if REDCONF_READ_ONLY == 0
REDSTATUS RedOsBDevWrite(uint8_t bVolNum, uint64_t ullSectorStart, uint32_t ulSectorCount, const void *pBuffer);
Expand Down
34 changes: 34 additions & 0 deletions os/stub/services/osbdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,40 @@ REDSTATUS RedOsBDevRead(
}


#if REDCONF_READAHEAD == 1
/** @brief Request asynchronous readahead of the specified sectors.
If the block device underlying @p bVolNum does not support readahead, or
would not benefit from it (think RAM disks), then this function can do
nothing and return.
This function cannot return an error since readahead is an optimization and
failures are not critical.
@param bVolNum The volume number of the volume whose block device
is being read from.
@param ullSectorStart The starting sector number.
@param ulSectorCount The number of sectors to readahead.
*/
void RedOsBDevReadahead(
uint8_t bVolNum,
uint64_t ullSectorStart,
uint32_t ulSectorCount)
{
if( (bVolNum >= REDCONF_VOLUME_COUNT)
|| !gaDisk[bVolNum].fOpen
|| (gaDisk[bVolNum].mode == BDEV_O_WRONLY)
|| !VOLUME_SECTOR_RANGE_IS_VALID(bVolNum, ullSectorStart, ulSectorCount))
{
REDERROR();
}
else
{
}
}
#endif /* REDCONF_READAHEAD == 1 */


#if REDCONF_READ_ONLY == 0
/** @brief Write sectors to a physical block device.
Expand Down

0 comments on commit e66ade5

Please sign in to comment.