From 473e28a6eebe47b386e625fd33b1c13b60f8e108 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 12 May 2007 16:21:19 +0000 Subject: simulated block device now contains a VFAT formated disk image git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@212 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/arch/sim/src/up_blockdevice.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'nuttx/arch/sim/src/up_blockdevice.c') diff --git a/nuttx/arch/sim/src/up_blockdevice.c b/nuttx/arch/sim/src/up_blockdevice.c index 1d4216e01..bf573b323 100644 --- a/nuttx/arch/sim/src/up_blockdevice.c +++ b/nuttx/arch/sim/src/up_blockdevice.c @@ -39,7 +39,6 @@ #include #include -#include #include #include #include @@ -50,8 +49,8 @@ * Private Definitions ****************************************************************************/ -#define NSECTORS 128 -#define SECTOR_SIZE 512 +#define NSECTORS 2048 +#define LOGICAL_SECTOR_SIZE 512 /**************************************************************************** * Private Types @@ -95,12 +94,12 @@ static const struct block_operations g_bops = static int up_open(FAR struct file *filp) { - filp->f_priv = (void*)malloc(NSECTORS*SECTOR_SIZE); + filp->f_priv = (void*)up_deviceimage(); return 0; } /**************************************************************************** - * Name: up_close + * Name: up_closel * * Description: close the block device * @@ -131,7 +130,7 @@ static ssize_t up_read(FAR struct file *filp, char *buffer, start_sector < NSECTORS && start_sector + nsectors < NSECTORS) { - memcpy(buffer, &src[start_sector*SECTOR_SIZE], nsectors*SECTOR_SIZE); + memcpy(buffer, &src[start_sector*LOGICAL_SECTOR_SIZE], nsectors*LOGICAL_SECTOR_SIZE); return OK; } else @@ -155,7 +154,7 @@ static ssize_t up_write(FAR struct file *filp, const char *buffer, start_sector < NSECTORS && start_sector + nsectors < NSECTORS) { - memcpy(&dest[start_sector*SECTOR_SIZE], buffer, nsectors*SECTOR_SIZE); + memcpy(&dest[start_sector*LOGICAL_SECTOR_SIZE], buffer, nsectors*LOGICAL_SECTOR_SIZE); return OK; } else @@ -177,7 +176,7 @@ static size_t up_geometry(FAR struct file *filp, struct geometry *geometry) { geometry->geo_available = (filp->f_priv != NULL); geometry->geo_nsectors = NSECTORS; - geometry->geo_sectorsize = SECTOR_SIZE; + geometry->geo_sectorsize = LOGICAL_SECTOR_SIZE; return OK; } return -EINVAL; -- cgit v1.2.3