Selaa lähdekoodia

Portability improvements

Petteri Aimonen 3 vuotta sitten
vanhempi
sitoutus
0b92893163
4 muutettua tiedostoa jossa 23 lisäystä ja 5 poistoa
  1. 10 1
      lib/SCSI2SD/src/firmware/scsi.h
  2. 4 0
      src/AzulSCSI_bootloader.cpp
  3. 4 4
      src/AzulSCSI_config.h
  4. 5 0
      src/AzulSCSI_disk.cpp

+ 10 - 1
lib/SCSI2SD/src/firmware/scsi.h

@@ -72,8 +72,17 @@ typedef enum
 } SCSI_COMPAT_MODE;
 
 // Maximum value for bytes-per-sector.
+#ifndef MAX_SECTOR_SIZE
 #define MAX_SECTOR_SIZE 8192
+#endif
+
+#ifndef MIN_SECTOR_SIZE
 #define MIN_SECTOR_SIZE 64
+#endif
+
+#ifndef SCSI2SD_BUFFER_SIZE
+#define SCSI2SD_BUFFER_SIZE (MAX_SECTOR_SIZE * 8)
+#endif
 
 // Shadow parameters, possibly not saved to flash yet.
 // Set via Mode Select
@@ -110,7 +119,7 @@ typedef struct
 	// TODO reduce this buffer size and add a proper cache
 	// Must be aligned for DMA
 	// 65536 bytes is the DMA limit
-	uint8_t data[MAX_SECTOR_SIZE * 8];
+	uint8_t data[SCSI2SD_BUFFER_SIZE];
 
 	TargetState targets[S2S_MAX_TARGETS];
 	TargetState* target;

+ 4 - 0
src/AzulSCSI_bootloader.cpp

@@ -5,6 +5,8 @@
 #include <SdFat.h>
 #include <string.h>
 
+#ifdef AZPLATFORM_BOOTLOADER_SIZE
+
 extern SdFs SD;
 extern FsFile g_logfile;
 
@@ -117,3 +119,5 @@ int bootloader_main(void)
 
     return 0;
 }
+
+#endif

+ 4 - 4
src/AzulSCSI_config.h

@@ -9,7 +9,9 @@
 #define CRASHFILE   "azulerr.txt"
 
 // Log buffer size in bytes, must be a power of 2
+#ifndef LOGBUFSIZE
 #define LOGBUFSIZE 16384
+#endif
 #define LOG_SAVE_INTERVAL_MS 1000
 
 // Watchdog timeout
@@ -22,7 +24,6 @@
 #define HDIMG_LUN_POS 3                 // Position to embed LUN numbers
 #define HDIMG_BLK_POS 5                 // Position to embed block size numbers
 #define MAX_FILE_PATH 64                // Maximum file name length
-#define MAX_BLOCKSIZE 8192              // Maximum BLOCK size
 
 // SCSI config
 #define NUM_SCSIID  7          // Maximum number of supported SCSI-IDs (The minimum is 0)
@@ -46,7 +47,6 @@
 #define DEFAULT_REQ_TYPE_SETUP_NS 500
 
 // Use prefetch buffer in read requests
+#ifndef PREFETCH_BUFFER_SIZE
 #define PREFETCH_BUFFER_SIZE 8192
-
-// Uncomment for building on revision 2022a prototype board
-/* #define AZULSCSI_2022A_REVISION 1 */
+#endif

+ 5 - 0
src/AzulSCSI_disk.cpp

@@ -8,6 +8,7 @@
 
 #include "AzulSCSI_disk.h"
 #include "AzulSCSI_log.h"
+#include "AzulSCSI_config.h"
 #include <minIni.h>
 #include <string.h>
 #include <SdFat.h>
@@ -17,6 +18,10 @@ extern "C" {
 #include <sd.h>
 }
 
+#ifndef PLATFORM_MAX_SCSI_SPEED
+#define PLATFORM_MAX_SCSI_SPEED S2S_CFG_SPEED_ASYNC_50
+#endif
+
 /***********************/
 /* Backing image files */
 /***********************/