projects
/
pub
/
USBasp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f0c7a11
)
Refactor macros in the VirtualFAT implementation of the incomplete Mass Storage bootl...
author
Dean Camera
<dean@fourwalledcubicle.com>
Sat, 9 Mar 2013 08:00:22 +0000
(08:00 +0000)
committer
Dean Camera
<dean@fourwalledcubicle.com>
Sat, 9 Mar 2013 08:00:22 +0000
(08:00 +0000)
Bootloaders/Incomplete/MassStorage/Lib/SCSI.c
patch
|
blob
|
blame
|
history
Bootloaders/Incomplete/MassStorage/Lib/VirtualFAT.c
patch
|
blob
|
blame
|
history
Bootloaders/Incomplete/MassStorage/Lib/VirtualFAT.h
patch
|
blob
|
blame
|
history
diff --git
a/Bootloaders/Incomplete/MassStorage/Lib/SCSI.c
b/Bootloaders/Incomplete/MassStorage/Lib/SCSI.c
index
c6596d4
..
7ab149c
100644
(file)
--- a/
Bootloaders/Incomplete/MassStorage/Lib/SCSI.c
+++ b/
Bootloaders/Incomplete/MassStorage/Lib/SCSI.c
@@
-214,7
+214,7
@@
static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterf
static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
{
uint32_t LastBlockAddressInLUN = (LUN_MEDIA_BLOCKS - 1);
static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
{
uint32_t LastBlockAddressInLUN = (LUN_MEDIA_BLOCKS - 1);
- uint32_t MediaBlockSize =
VIRTUAL_MEMORY_BLOCK_SIZE
;
+ uint32_t MediaBlockSize =
SECTOR_SIZE_BYTES
;
Endpoint_Write_Stream_BE(&LastBlockAddressInLUN, sizeof(LastBlockAddressInLUN), NULL);
Endpoint_Write_Stream_BE(&MediaBlockSize, sizeof(MediaBlockSize), NULL);
Endpoint_Write_Stream_BE(&LastBlockAddressInLUN, sizeof(LastBlockAddressInLUN), NULL);
Endpoint_Write_Stream_BE(&MediaBlockSize, sizeof(MediaBlockSize), NULL);
@@
-292,7
+292,7
@@
static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
VirtualFAT_WriteBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);
/* Update the bytes transferred counter and succeed the command */
VirtualFAT_WriteBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);
/* Update the bytes transferred counter and succeed the command */
- MSInterfaceInfo->State.CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks *
VIRTUAL_MEMORY_BLOCK_SIZE
);
+ MSInterfaceInfo->State.CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks *
SECTOR_SIZE_BYTES
);
return true;
}
return true;
}
diff --git
a/Bootloaders/Incomplete/MassStorage/Lib/VirtualFAT.c
b/Bootloaders/Incomplete/MassStorage/Lib/VirtualFAT.c
index
2365ba5
..
883586c
100644
(file)
--- a/
Bootloaders/Incomplete/MassStorage/Lib/VirtualFAT.c
+++ b/
Bootloaders/Incomplete/MassStorage/Lib/VirtualFAT.c
@@
-30,15
+30,6
@@
#include "VirtualFAT.h"
#include "VirtualFAT.h"
-#define FAT_TIME(h, m, s) ((h << 11) | (m << 5) | (s >> 1))
-#define FAT_DATE(d, m, y) (((y - 1980) << 9) | (m << 5) | (d << 0))
-
-#define SECTOR_SIZE_BYTES VIRTUAL_MEMORY_BLOCK_SIZE
-#define SECTOR_PER_CLUSTER 4
-#define CLUSTER_SIZE_BYTES (SECTOR_PER_CLUSTER * SECTOR_SIZE_BYTES)
-
-#define FILE_CLUSTERS(size) (size / CLUSTER_SIZE_BYTES)
-
static const FATBootBlock_t BootBlock =
{
.Bootstrap = {0xEB, 0x3C, 0x90},
static const FATBootBlock_t BootBlock =
{
.Bootstrap = {0xEB, 0x3C, 0x90},
@@
-47,7
+38,7
@@
static const FATBootBlock_t BootBlock =
.SectorsPerCluster = SECTOR_PER_CLUSTER,
.ReservedSectors = 1,
.FATCopies = 2,
.SectorsPerCluster = SECTOR_PER_CLUSTER,
.ReservedSectors = 1,
.FATCopies = 2,
- .RootDirectoryEntries =
SECTOR_SIZE_BYTES / sizeof(FATDirectoryEntry_t
),
+ .RootDirectoryEntries =
(SECTOR_SIZE_BYTES / sizeof(FATDirectoryEntry_t)
),
.TotalSectors16 = LUN_MEDIA_BLOCKS,
.MediaDescriptor = 0xF8,
.SectorsPerFAT = 1,
.TotalSectors16 = LUN_MEDIA_BLOCKS,
.MediaDescriptor = 0xF8,
.SectorsPerFAT = 1,
@@
-76,6
+67,7
@@
static FATDirectoryEntry_t FirmwareFileEntry =
.FileSizeBytes = 2049,
};
.FileSizeBytes = 2049,
};
+
static void WriteBlock(uint16_t BlockNumber)
{
uint8_t BlockBuffer[512];
static void WriteBlock(uint16_t BlockNumber)
{
uint8_t BlockBuffer[512];
@@
-156,6
+148,8
@@
void VirtualFAT_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
{
uint16_t CurrentBlock = (uint16_t)BlockAddress;
{
uint16_t CurrentBlock = (uint16_t)BlockAddress;
+ /* Emulated FAT is performed per-block, pass each requested block index
+ * to the emulation function */
while (TotalBlocks--)
WriteBlock(CurrentBlock++);
}
while (TotalBlocks--)
WriteBlock(CurrentBlock++);
}
@@
-166,6
+160,8
@@
void VirtualFAT_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
{
uint16_t CurrentBlock = (uint16_t)BlockAddress;
{
uint16_t CurrentBlock = (uint16_t)BlockAddress;
+ /* Emulated FAT is performed per-block, pass each requested block index
+ * to the emulation function */
while (TotalBlocks--)
ReadBlock(CurrentBlock++);
}
while (TotalBlocks--)
ReadBlock(CurrentBlock++);
}
diff --git
a/Bootloaders/Incomplete/MassStorage/Lib/VirtualFAT.h
b/Bootloaders/Incomplete/MassStorage/Lib/VirtualFAT.h
index
760fb40
..
156760a
100644
(file)
--- a/
Bootloaders/Incomplete/MassStorage/Lib/VirtualFAT.h
+++ b/
Bootloaders/Incomplete/MassStorage/Lib/VirtualFAT.h
@@
-38,11
+38,17
@@
#include <LUFA/Drivers/USB/USB.h>
/* Macros: */
#include <LUFA/Drivers/USB/USB.h>
/* Macros: */
- #define VIRTUAL_MEMORY_BLOCK_SIZE 512
+ #define FIRMWARE_FILE_SIZE (FLASHEND + 1UL)
+ #define FILE_CLUSTERS(size) ((size / CLUSTER_SIZE_BYTES) + ((size % CLUSTER_SIZE_BYTES) ? 1 : 0))
- #define FIRMWARE_FILE_SIZE (FLASHEND + 1UL)
+ #define SECTOR_SIZE_BYTES 512
+ #define SECTOR_PER_CLUSTER 4
+ #define CLUSTER_SIZE_BYTES (SECTOR_PER_CLUSTER * SECTOR_SIZE_BYTES)
- #define LUN_MEDIA_BLOCKS ((FIRMWARE_FILE_SIZE / VIRTUAL_MEMORY_BLOCK_SIZE) + 32)
+ #define LUN_MEDIA_BLOCKS ((FIRMWARE_FILE_SIZE / SECTOR_SIZE_BYTES) + 32)
+
+ #define FAT_TIME(h, m, s) ((h << 11) | (m << 5) | (s >> 1))
+ #define FAT_DATE(d, m, y) (((y - 1980) << 9) | (m << 5) | (d << 0))
/* Type Definitions: */
typedef struct
/* Type Definitions: */
typedef struct