···2021/* This is intended to be #included into the ATA driver */
2200000000000000000000000000000000000000000000000000023#ifdef MAX_PHYS_SECTOR_SIZE
2425#ifdef MAX_VARIABLE_LOG_SECTOR
···40/* buffer for reading and writing large physical sectors */
41static struct sector_cache_entry sector_cache STORAGE_ALIGN_ATTR;
42static uint16_t phys_sector_mult = 1;
000004344static int cache_sector(sector_t sector)
45{
···2021/* This is intended to be #included into the ATA driver */
2223+static sector_t total_sectors;
24+static uint32_t log_sector_size;
25+static uint16_t identify_info[ATA_IDENTIFY_WORDS] STORAGE_ALIGN_ATTR;
26+#ifdef HAVE_LBA48
27+static bool ata_lba48 = false; /* set for 48 bit addressing */
28+#endif
29+static bool canflush = true;
30+static int spinup_time = 0;
31+static struct mutex ata_mutex SHAREDBSS_ATTR;
32+33+int ata_spinup_time(void)
34+{
35+ return spinup_time;
36+}
37+38+#ifdef STORAGE_GET_INFO
39+void ata_get_info(IF_MD(int drive,)struct storage_info *info)
40+{
41+ unsigned short *src,*dest;
42+ static char vendor[8];
43+ static char product[16];
44+ static char revision[4];
45+#ifdef HAVE_MULTIDRIVE
46+ (void)drive; /* unused for now */
47+#endif
48+ int i;
49+50+ info->sector_size = log_sector_size;
51+ info->num_sectors = total_sectors;
52+53+ src = (unsigned short*)&identify_info[27];
54+ dest = (unsigned short*)vendor;
55+ for (i=0;i<4;i++)
56+ dest[i] = htobe16(src[i]);
57+ info->vendor=vendor;
58+59+ src = (unsigned short*)&identify_info[31];
60+ dest = (unsigned short*)product;
61+ for (i=0;i<8;i++)
62+ dest[i] = htobe16(src[i]);
63+ info->product=product;
64+65+ src = (unsigned short*)&identify_info[23];
66+ dest = (unsigned short*)revision;
67+ for (i=0;i<2;i++)
68+ dest[i] = htobe16(src[i]);
69+ info->revision=revision;
70+}
71+#endif
72+73+74#ifdef MAX_PHYS_SECTOR_SIZE
7576#ifdef MAX_VARIABLE_LOG_SECTOR
···91/* buffer for reading and writing large physical sectors */
92static struct sector_cache_entry sector_cache STORAGE_ALIGN_ATTR;
93static uint16_t phys_sector_mult = 1;
94+95+static int ata_transfer_sectors(uint64_t start,
96+ int incount,
97+ void* inbuf,
98+ int write);
99100static int cache_sector(sector_t sector)
101{
+2-52
firmware/drivers/ata.c
···9091static int ata_state = ATA_BOOT;
9293-static struct mutex ata_mutex SHAREDBSS_ATTR;
94static int ata_device; /* device 0 (master) or 1 (slave) */
9596-static int spinup_time = 0;
97#if (CONFIG_LED == LED_REAL)
98static bool ata_led_enabled = true;
99static bool ata_led_on = false;
100#endif
101102static long sleep_timeout = 5*HZ;
103-#ifdef HAVE_LBA48
104-static bool ata_lba48 = false; /* set for 48 bit addressing */
105-#endif
106-static bool canflush = true;
107108static long last_disk_activity = -1;
109#ifdef HAVE_ATA_POWER_OFF
110static long power_off_tick = 0;
111#endif
112113-static sector_t total_sectors;
114-static uint32_t log_sector_size;
115static uint8_t multisectors; /* number of supported multisectors */
116-117-static unsigned short identify_info[ATA_IDENTIFY_WORDS] STORAGE_ALIGN_ATTR;
118119#ifdef HAVE_ATA_DMA
120static int dma_mode = 0;
···146 return false;
147#endif
148}
00149150#ifndef ATA_TARGET_POLLING
151static ICODE_ATTR int wait_for_bsy(void)
···593594 return ret;
595}
596-597-#include "ata-common.c"
598599#ifndef MAX_PHYS_SECTOR_SIZE
600int ata_read_sectors(IF_MD(int drive,)
···1217{
1218 return last_disk_activity;
1219}
1220-1221-int ata_spinup_time(void)
1222-{
1223- return spinup_time;
1224-}
1225-1226-#ifdef STORAGE_GET_INFO
1227-void ata_get_info(IF_MD(int drive,)struct storage_info *info)
1228-{
1229- unsigned short *src,*dest;
1230- static char vendor[8];
1231- static char product[16];
1232- static char revision[4];
1233-#ifdef HAVE_MULTIDRIVE
1234- (void)drive; /* unused for now */
1235-#endif
1236- int i;
1237-1238- info->sector_size = log_sector_size;
1239- info->num_sectors = total_sectors;
1240-1241- src = (unsigned short*)&identify_info[27];
1242- dest = (unsigned short*)vendor;
1243- for (i=0;i<4;i++)
1244- dest[i] = htobe16(src[i]);
1245- info->vendor=vendor;
1246-1247- src = (unsigned short*)&identify_info[31];
1248- dest = (unsigned short*)product;
1249- for (i=0;i<8;i++)
1250- dest[i] = htobe16(src[i]);
1251- info->product=product;
1252-1253- src = (unsigned short*)&identify_info[23];
1254- dest = (unsigned short*)revision;
1255- for (i=0;i<2;i++)
1256- dest[i] = htobe16(src[i]);
1257- info->revision=revision;
1258-}
1259-#endif
12601261#ifdef HAVE_ATA_DMA
1262/* Returns last DMA mode as set by set_features() */
···9091static int ata_state = ATA_BOOT;
92093static int ata_device; /* device 0 (master) or 1 (slave) */
94095#if (CONFIG_LED == LED_REAL)
96static bool ata_led_enabled = true;
97static bool ata_led_on = false;
98#endif
99100static long sleep_timeout = 5*HZ;
0000101102static long last_disk_activity = -1;
103#ifdef HAVE_ATA_POWER_OFF
104static long power_off_tick = 0;
105#endif
10600107static uint8_t multisectors; /* number of supported multisectors */
00108109#ifdef HAVE_ATA_DMA
110static int dma_mode = 0;
···136 return false;
137#endif
138}
139+140+#include "ata-common.c"
141142#ifndef ATA_TARGET_POLLING
143static ICODE_ATTR int wait_for_bsy(void)
···585586 return ret;
587}
00588589#ifndef MAX_PHYS_SECTOR_SIZE
590int ata_read_sectors(IF_MD(int drive,)
···1207{
1208 return last_disk_activity;
1209}
000000000000000000000000000000000000000012101211#ifdef HAVE_ATA_DMA
1212/* Returns last DMA mode as set by set_features() */