Index: emcore/trunk/tools/emcore.py |
— | — | @@ -886,29 +886,31 @@ |
887 | 887 | sector = self._hexint(sector)
|
888 | 888 | count = self._hexint(count)
|
889 | 889 | buffsize = self._hexint(buffsize)
|
890 | | - if buffer is None:
|
891 | | - buffer = self.emcore.malloc(buffsize)
|
892 | | - malloc = True
|
893 | | - else:
|
894 | | - buffer = self._hexint(buffer)
|
895 | | - malloc = False
|
896 | 890 | try:
|
| 891 | + f = open(file, 'wb')
|
| 892 | + except IOError:
|
| 893 | + raise ArgumentError("Could not open local file for writing.")
|
| 894 | + try:
|
| 895 | + if buffer is None:
|
| 896 | + buffer = self.emcore.malloc(buffsize)
|
| 897 | + malloc = True
|
| 898 | + else:
|
| 899 | + buffer = self._hexint(buffer)
|
| 900 | + malloc = False
|
897 | 901 | try:
|
898 | | - f = open(file, 'wb')
|
899 | | - except IOError:
|
900 | | - raise ArgumentError("Could not open local file for writing.")
|
901 | | - self.logger.info("Reading volume %s sectors %X - %X to %s..." % (volume, sector, sector + count - 1, file))
|
902 | | - storageinfo = self.emcore.storage_get_info(volume)
|
903 | | - while count > 0:
|
904 | | - sectors = min(count, int(buffsize / storageinfo.sectorsize))
|
905 | | - self.emcore.storage_read_sectors_md(volume, sector, sectors, buffsize, buffer)
|
906 | | - f.write(self.emcore.read(buffer, storageinfo.sectorsize * sectors))
|
907 | | - sector = sector + sectors
|
908 | | - count = count - sectors
|
| 902 | + self.logger.info("Reading volume %s sectors %X - %X to %s..." % (volume, sector, sector + count - 1, file))
|
| 903 | + storageinfo = self.emcore.storage_get_info(volume)
|
| 904 | + while count > 0:
|
| 905 | + sectors = min(count, int(buffsize / storageinfo.sectorsize))
|
| 906 | + self.emcore.storage_read_sectors_md(volume, sector, sectors, buffsize, buffer)
|
| 907 | + f.write(self.emcore.read(buffer, storageinfo.sectorsize * sectors))
|
| 908 | + sector = sector + sectors
|
| 909 | + count = count - sectors
|
| 910 | + finally:
|
| 911 | + if malloc == True:
|
| 912 | + self.emcore.free(buffer)
|
| 913 | + finally:
|
909 | 914 | f.close()
|
910 | | - finally:
|
911 | | - if malloc == True:
|
912 | | - self.emcore.free(buffer)
|
913 | 915 | self.logger.info("done\n")
|
914 | 916 |
|
915 | 917 | @command
|
— | — | @@ -921,33 +923,35 @@ |
922 | 924 | sector = self._hexint(sector)
|
923 | 925 | count = self._hexint(count)
|
924 | 926 | buffsize = self._hexint(buffsize)
|
925 | | - if buffer is None:
|
926 | | - buffer = self.emcore.malloc(buffsize)
|
927 | | - malloc = True
|
928 | | - else:
|
929 | | - buffer = self._hexint(buffer)
|
930 | | - malloc = False
|
931 | 927 | try:
|
| 928 | + f = open(file, 'rb')
|
| 929 | + except IOError:
|
| 930 | + raise ArgumentError("Could not open local file for reading.")
|
| 931 | + try:
|
| 932 | + if buffer is None:
|
| 933 | + buffer = self.emcore.malloc(buffsize)
|
| 934 | + malloc = True
|
| 935 | + else:
|
| 936 | + buffer = self._hexint(buffer)
|
| 937 | + malloc = False
|
932 | 938 | try:
|
933 | | - f = open(file, 'rb')
|
934 | | - except IOError:
|
935 | | - raise ArgumentError("Could not open local file for reading.")
|
936 | | - self.logger.info("Writing %s to volume %s sectors %X - %X..." % (file, volume, sector, sector + count - 1))
|
937 | | - storageinfo = self.emcore.storage_get_info(volume)
|
938 | | - while count > 0:
|
939 | | - sectors = min(count, int(buffsize / storageinfo.sectorsize))
|
940 | | - bytes = storageinfo.sectorsize * sectors
|
941 | | - data = f.read(bytes)
|
942 | | - if len(data) == 0: break
|
943 | | - while len(data) < bytes: data = data + f.read(bytes - len(data))
|
944 | | - self.emcore.write(buffer, data)
|
945 | | - self.emcore.storage_write_sectors_md(volume, sector, sectors, buffsize, buffer)
|
946 | | - sector = sector + sectors
|
947 | | - count = count - sectors
|
| 939 | + self.logger.info("Writing %s to volume %s sectors %X - %X..." % (file, volume, sector, sector + count - 1))
|
| 940 | + storageinfo = self.emcore.storage_get_info(volume)
|
| 941 | + while count > 0:
|
| 942 | + sectors = min(count, int(buffsize / storageinfo.sectorsize))
|
| 943 | + bytes = storageinfo.sectorsize * sectors
|
| 944 | + data = f.read(bytes)
|
| 945 | + if len(data) == 0: break
|
| 946 | + while len(data) < bytes: data = data + f.read(bytes - len(data))
|
| 947 | + self.emcore.write(buffer, data)
|
| 948 | + self.emcore.storage_write_sectors_md(volume, sector, sectors, buffsize, buffer)
|
| 949 | + sector = sector + sectors
|
| 950 | + count = count - sectors
|
| 951 | + finally:
|
| 952 | + if malloc == True:
|
| 953 | + self.emcore.free(buffer)
|
| 954 | + finally:
|
948 | 955 | f.close()
|
949 | | - finally:
|
950 | | - if malloc == True:
|
951 | | - self.emcore.free(buffer)
|
952 | 956 | self.logger.info("done\n")
|
953 | 957 |
|
954 | 958 | @command
|
— | — | @@ -1014,29 +1018,33 @@ |
1015 | 1019 | [buffer]: buffer address (optional)
|
1016 | 1020 | """
|
1017 | 1021 | buffsize = self._hexint(buffsize)
|
1018 | | - if buffer is None:
|
1019 | | - buffer = self.emcore.malloc(buffsize)
|
1020 | | - malloc = True
|
1021 | | - else:
|
1022 | | - buffer = self._hexint(buffer)
|
1023 | | - malloc = False
|
1024 | 1022 | try:
|
| 1023 | + f = open(localname, 'wb')
|
| 1024 | + except IOError:
|
| 1025 | + raise ArgumentError("Could not open local file for writing.")
|
| 1026 | + try:
|
| 1027 | + if buffer is None:
|
| 1028 | + buffer = self.emcore.malloc(buffsize)
|
| 1029 | + malloc = True
|
| 1030 | + else:
|
| 1031 | + buffer = self._hexint(buffer)
|
| 1032 | + malloc = False
|
1025 | 1033 | try:
|
1026 | | - f = open(localname, 'wb')
|
1027 | | - except IOError:
|
1028 | | - raise ArgumentError("Could not open local file for writing.")
|
1029 | | - self.logger.info("Downloading file " + remotename + " to " + localname + "...")
|
1030 | | - fd = self.emcore.file_open(remotename, 0)
|
1031 | | - size = self.emcore.file_size(fd)
|
1032 | | - while size > 0:
|
1033 | | - bytes = self.emcore.file_read(fd, buffsize, buffer)
|
1034 | | - f.write(self.emcore.read(buffer, bytes))
|
1035 | | - size = size - bytes
|
1036 | | - self.emcore.file_close(fd)
|
| 1034 | + self.logger.info("Downloading file " + remotename + " to " + localname + "...")
|
| 1035 | + fd = self.emcore.file_open(remotename, 0)
|
| 1036 | + try:
|
| 1037 | + size = self.emcore.file_size(fd)
|
| 1038 | + while size > 0:
|
| 1039 | + bytes = self.emcore.file_read(fd, buffsize, buffer)
|
| 1040 | + f.write(self.emcore.read(buffer, bytes))
|
| 1041 | + size = size - bytes
|
| 1042 | + finally:
|
| 1043 | + self.emcore.file_close(fd)
|
| 1044 | + finally:
|
| 1045 | + if malloc == True:
|
| 1046 | + self.emcore.free(buffer)
|
| 1047 | + finally:
|
1037 | 1048 | f.close()
|
1038 | | - finally:
|
1039 | | - if malloc == True:
|
1040 | | - self.emcore.free(buffer)
|
1041 | 1049 | self.logger.info(" done\n")
|
1042 | 1050 |
|
1043 | 1051 | @command
|
— | — | @@ -1049,29 +1057,30 @@ |
1050 | 1058 | [buffer]: buffer address (optional)
|
1051 | 1059 | """
|
1052 | 1060 | buffsize = self._hexint(buffsize)
|
1053 | | - if buffer is None:
|
1054 | | - buffer = self.emcore.malloc(buffsize)
|
1055 | | - malloc = True
|
1056 | | - else:
|
1057 | | - buffer = self._hexint(buffer)
|
1058 | | - malloc = False
|
| 1061 | + handle = self.emcore.dir_open(remotepath)
|
1059 | 1062 | try:
|
1060 | | - try: os.mkdir(localpath)
|
1061 | | - except: pass
|
1062 | | -
|
1063 | | - handle = self.emcore.dir_open(remotepath)
|
1064 | | - while True:
|
1065 | | - try:
|
1066 | | - entry = self.emcore.dir_read(handle)
|
1067 | | - if entry.name == "." or entry.name == "..": continue
|
1068 | | - elif entry.attributes & 0x10:
|
1069 | | - self.gettree(remotepath + "/" + entry.name, localpath + "/" + entry.name, buffsize, buffer)
|
1070 | | - else: self.get(remotepath + "/" + entry.name, localpath + "/" + entry.name, buffsize, buffer)
|
1071 | | - except: break
|
| 1063 | + if buffer is None:
|
| 1064 | + buffer = self.emcore.malloc(buffsize)
|
| 1065 | + malloc = True
|
| 1066 | + else:
|
| 1067 | + buffer = self._hexint(buffer)
|
| 1068 | + malloc = False
|
| 1069 | + try:
|
| 1070 | + try: os.mkdir(localpath)
|
| 1071 | + except: pass
|
| 1072 | + while True:
|
| 1073 | + try:
|
| 1074 | + entry = self.emcore.dir_read(handle)
|
| 1075 | + if entry.name == "." or entry.name == "..": continue
|
| 1076 | + elif entry.attributes & 0x10:
|
| 1077 | + self.gettree(remotepath + "/" + entry.name, localpath + "/" + entry.name, buffsize, buffer)
|
| 1078 | + else: self.get(remotepath + "/" + entry.name, localpath + "/" + entry.name, buffsize, buffer)
|
| 1079 | + except: break
|
| 1080 | + finally:
|
| 1081 | + if malloc == True:
|
| 1082 | + self.emcore.free(buffer)
|
| 1083 | + finally:
|
1072 | 1084 | self.emcore.dir_close(handle)
|
1073 | | - finally:
|
1074 | | - if malloc == True:
|
1075 | | - self.emcore.free(buffer)
|
1076 | 1085 |
|
1077 | 1086 | @command
|
1078 | 1087 | def put(self, localname, remotename, buffsize = 0x10000, buffer = None):
|
— | — | @@ -1083,31 +1092,35 @@ |
1084 | 1093 | [buffer]: buffer address (optional)
|
1085 | 1094 | """
|
1086 | 1095 | buffsize = self._hexint(buffsize)
|
1087 | | - if buffer is None:
|
1088 | | - buffer = self.emcore.malloc(buffsize)
|
1089 | | - malloc = True
|
1090 | | - else:
|
1091 | | - buffer = self._hexint(buffer)
|
1092 | | - malloc = False
|
1093 | 1096 | try:
|
| 1097 | + f = open(localname, 'rb')
|
| 1098 | + except IOError:
|
| 1099 | + raise ArgumentError("Could not open local file for reading.")
|
| 1100 | + try:
|
| 1101 | + if buffer is None:
|
| 1102 | + buffer = self.emcore.malloc(buffsize)
|
| 1103 | + malloc = True
|
| 1104 | + else:
|
| 1105 | + buffer = self._hexint(buffer)
|
| 1106 | + malloc = False
|
1094 | 1107 | try:
|
1095 | | - f = open(localname, 'rb')
|
1096 | | - except IOError:
|
1097 | | - raise ArgumentError("Could not open local file for reading.")
|
1098 | | - self.logger.info("Uploading file " + localname + " to " + remotename + "...\n")
|
1099 | | - fd = self.emcore.file_open(remotename, 0x15)
|
1100 | | - while True:
|
1101 | | - data = f.read(buffsize)
|
1102 | | - if len(data) == 0: break
|
1103 | | - self.emcore.write(buffer, data)
|
1104 | | - bytes = 0
|
1105 | | - while bytes < len(data):
|
1106 | | - bytes = bytes + self.emcore.file_write(fd, len(data) - bytes, buffer + bytes)
|
1107 | | - self.emcore.file_close(fd)
|
| 1108 | + self.logger.info("Uploading file " + localname + " to " + remotename + "...")
|
| 1109 | + fd = self.emcore.file_open(remotename, 0x15)
|
| 1110 | + try:
|
| 1111 | + while True:
|
| 1112 | + data = f.read(buffsize)
|
| 1113 | + if len(data) == 0: break
|
| 1114 | + self.emcore.write(buffer, data)
|
| 1115 | + bytes = 0
|
| 1116 | + while bytes < len(data):
|
| 1117 | + bytes = bytes + self.emcore.file_write(fd, len(data) - bytes, buffer + bytes)
|
| 1118 | + finally:
|
| 1119 | + self.emcore.file_close(fd)
|
| 1120 | + finally:
|
| 1121 | + if malloc == True:
|
| 1122 | + self.emcore.free(buffer)
|
| 1123 | + finally:
|
1108 | 1124 | f.close()
|
1109 | | - finally:
|
1110 | | - if malloc == True:
|
1111 | | - self.emcore.free(buffer)
|
1112 | 1125 | self.logger.info(" done\n")
|
1113 | 1126 |
|
1114 | 1127 | @command
|
— | — | @@ -1137,7 +1150,7 @@ |
1138 | 1151 | try: self.mkdir(prefix + dir)
|
1139 | 1152 | except: self.logger.info(" failed\n")
|
1140 | 1153 | for f in d[2]:
|
1141 | | - if not prefix.find("/.svn/") > -1:
|
| 1154 | + if prefix.find("/.svn/") == -1:
|
1142 | 1155 | self.put(d[0] + "/" + f, prefix + f, buffsize, buffer)
|
1143 | 1156 | finally:
|
1144 | 1157 | if malloc == True:
|
Index: emcore/trunk/tools/libemcore.py |
— | — | @@ -222,6 +222,7 @@ |
223 | 223 | din_maxsize = self.lib.dev.packetsizelimit.din
|
224 | 224 | data = ""
|
225 | 225 | (headsize, bodysize, tailsize) = self._alignsplit(addr, size, cin_maxsize, 16)
|
| 226 | + self.logger.debug("Downloading %d bytes from 0x%x, split as (%d/%d/%d)\n" % (size, addr, headsize, bodysize, tailsize))
|
226 | 227 | if headsize != 0:
|
227 | 228 | data += self._readmem(addr, headsize)
|
228 | 229 | addr += headsize
|
— | — | @@ -247,6 +248,7 @@ |
248 | 249 | cout_maxsize = self.lib.dev.packetsizelimit.cout - self.lib.headersize
|
249 | 250 | dout_maxsize = self.lib.dev.packetsizelimit.dout
|
250 | 251 | (headsize, bodysize, tailsize) = self._alignsplit(addr, len(data), cout_maxsize, 16)
|
| 252 | + self.logger.debug("Uploading %d bytes to 0x%x, split as (%d/%d/%d)\n" % (len(data), addr, headsize, bodysize, tailsize))
|
251 | 253 | offset = 0
|
252 | 254 | if headsize != 0:
|
253 | 255 | self._writemem(addr, data[offset:offset+headsize])
|
— | — | @@ -272,7 +274,6 @@ |
273 | 275 | Returns the address where 'data' is stored
|
274 | 276 | """
|
275 | 277 | addr = self.malloc(len(data))
|
276 | | - self.logger.debug("Uploading %d bytes to 0x%x\n" % (len(data), addr))
|
277 | 278 | self.write(addr, data)
|
278 | 279 | return addr
|
279 | 280 |
|
— | — | @@ -618,37 +619,25 @@ |
619 | 620 | return result
|
620 | 621 |
|
621 | 622 | @command(timeout = 50000)
|
622 | | - def storage_read_sectors_md(self, volume, sector, count, size = 0x100000, addr = None):
|
623 | | - """ Read sectors from as storage device. If addr is not given it allocates a buffer itself. """
|
624 | | - if addr is None:
|
625 | | - addr = self.malloc(size)
|
626 | | - malloc = True
|
627 | | - else:
|
628 | | - malloc = False
|
629 | | - try:
|
630 | | - result = self.lib.monitorcommand(struct.pack("IIQIIII", 28, volume, sector, count, addr, 0, 0), "III", ("rc", None, None))
|
631 | | - finally:
|
632 | | - if malloc == True:
|
633 | | - self.free(addr)
|
| 623 | + def storage_read_sectors_md(self, volume, sector, count, addr):
|
| 624 | + """ Read sectors from as storage device """
|
| 625 | + result = self.lib.monitorcommand(struct.pack("IIQIIII", 28, volume, sector, count, addr, 0, 0), "III", ("rc", None, None))
|
634 | 626 | if result.rc > 0x80000000:
|
635 | 627 | raise DeviceError("storage_read_sectors_md(volume=%d, sector=%d, count=%d, addr=0x%08X) failed with RC 0x%08X" % (volume, sector, count, addr, rc))
|
636 | | -
|
637 | | - def storage_write_sectors_md(self, volume, sector, count, size = 0x100000, addr = None):
|
638 | | - """ Read sectors from as storage device. If addr is not given it allocates a buffer itself. """
|
639 | | - if addr is None:
|
640 | | - addr = self.malloc(size)
|
641 | | - malloc = True
|
642 | | - else:
|
643 | | - malloc = False
|
644 | | - try:
|
645 | | - result = self.lib.monitorcommand(struct.pack("IIQIIII", 29, volume, sector, count, addr, 0, 0), "III", ("rc", None, None))
|
646 | | - finally:
|
647 | | - if malloc == True:
|
648 | | - self.free(addr)
|
| 628 | +
|
| 629 | + @command(timeout = 50000)
|
| 630 | + def storage_write_sectors_md(self, volume, sector, count, addr):
|
| 631 | + """ Read sectors from as storage device """
|
| 632 | + result = self.lib.monitorcommand(struct.pack("IIQIIII", 29, volume, sector, count, addr, 0, 0), "III", ("rc", None, None))
|
649 | 633 | if result.rc > 0x80000000:
|
650 | | - raise DeviceError("storage_read_sectors_md(volume=%d, sector=%d, count=%d, addr=0x%08X) failed with RC 0x%08X" % (volume, sector, count, addr, rc))
|
| 634 | + raise DeviceError("storage_write_sectors_md(volume=%d, sector=%d, count=%d, addr=0x%08X) failed with RC 0x%08X" % (volume, sector, count, addr, rc))
|
651 | 635 |
|
652 | 636 | @command(timeout = 30000)
|
| 637 | + def fat_enable_flushing(self, state):
|
| 638 | + """ Enables/disables flushing the FAT cache after every transaction """
|
| 639 | + self.lib.monitorcommand(struct.pack("IIII", 58, state, 0, 0), "III", (None, None, None))
|
| 640 | +
|
| 641 | + @command(timeout = 30000)
|
653 | 642 | def file_open(self, filename, mode):
|
654 | 643 | """ Opens a file and returns the handle """
|
655 | 644 | result = self.lib.monitorcommand(struct.pack("IIII%dsB" % len(filename), 30, mode, 0, 0, filename, 0), "III", ("fd", None, None))
|
— | — | @@ -665,7 +654,7 @@ |
666 | 655 | return result.size
|
667 | 656 |
|
668 | 657 | @command(timeout = 30000)
|
669 | | - def file_read(self, fd, size = 0x100000, addr = None):
|
| 658 | + def file_read(self, fd, size = 0x10000, addr = None):
|
670 | 659 | """ Reads data from a file referenced by a handle. If addr is not given it allocates a buffer itself. """
|
671 | 660 | if addr is None:
|
672 | 661 | addr = self.malloc(size)
|
— | — | @@ -674,26 +663,18 @@ |
675 | 664 | malloc = False
|
676 | 665 | try:
|
677 | 666 | result = self.lib.monitorcommand(struct.pack("IIII", 32, fd, addr, size), "III", ("rc", None, None))
|
678 | | - finally:
|
| 667 | + if result.rc > 0x80000000:
|
| 668 | + raise DeviceError("file_read(fd=%d, addr=0x%08X, size=0x%08X) failed with RC=0x%08X, errno=%d" % (fd, addr, size, result.rc, self.errno()))
|
| 669 | + except:
|
679 | 670 | if malloc == True:
|
680 | 671 | self.free(addr)
|
681 | | - if result.rc > 0x80000000:
|
682 | | - raise DeviceError("file_read(fd=%d, addr=0x%08X, size=0x%08X) failed with RC=0x%08X, errno=%d" % (fd, addr, size, result.rc, self.errno()))
|
683 | | - return result.rc
|
| 672 | + raise
|
| 673 | + return Bunch(rc = result.rc, addr = addr)
|
684 | 674 |
|
685 | 675 | @command(timeout = 30000)
|
686 | | - def file_write(self, fd, size = 0x100000, addr = None):
|
687 | | - """ Writes data from a file referenced by a handle. If addr is not given it allocates a buffer itself. """
|
688 | | - if addr is None:
|
689 | | - addr = self.malloc(size)
|
690 | | - malloc = True
|
691 | | - else:
|
692 | | - malloc = False
|
693 | | - try:
|
694 | | - result = self.lib.monitorcommand(struct.pack("IIII", 33, fd, addr, size), "III", ("rc", None, None))
|
695 | | - finally:
|
696 | | - if malloc == True:
|
697 | | - self.free(addr)
|
| 676 | + def file_write(self, fd, size, addr):
|
| 677 | + """ Writes data from a file referenced by a handle. """
|
| 678 | + result = self.lib.monitorcommand(struct.pack("IIII", 33, fd, addr, size), "III", ("rc", None, None))
|
698 | 679 | if result.rc > 0x80000000:
|
699 | 680 | raise DeviceError("file_write(fd=%d, addr=0x%08X, size=0x%08X) failed with RC=0x%08X, errno=%d" % (fd, addr, size, result.rc, self.errno()))
|
700 | 681 | return result.rc
|
Index: emcore/trunk/export/syscallwrappers.h |
— | — | @@ -197,6 +197,7 @@ |
198 | 198 | #define get_library_ext __emcore_syscall->get_library_ext
|
199 | 199 | #define release_library __emcore_syscall->release_library
|
200 | 200 | #define release_library_ext __emcore_syscall->release_library_ext
|
| 201 | +#define fat_enable_flushing __emcore_syscall->fat_enable_flushing
|
201 | 202 |
|
202 | 203 |
|
203 | 204 | #endif
|
Index: emcore/trunk/export/syscallapi.h |
— | — | @@ -33,6 +33,7 @@ |
34 | 34 | #include "../disk.h"
|
35 | 35 | #include "../dir.h"
|
36 | 36 | #include "../file.h"
|
| 37 | +#include "../fat.h"
|
37 | 38 | #include "../format.h"
|
38 | 39 | #include "../drawing.h"
|
39 | 40 | #include "../lcdconsole.h"
|
— | — | @@ -243,6 +244,7 @@ |
244 | 245 | typeof(get_library_ext) *get_library_ext;
|
245 | 246 | typeof(release_library) *release_library;
|
246 | 247 | typeof(release_library_ext) *release_library_ext;
|
| 248 | + typeof(fat_enable_flushing) *fat_enable_flushing;
|
247 | 249 | };
|
248 | 250 |
|
249 | 251 |
|
Index: emcore/trunk/syscallapi.c |
— | — | @@ -208,5 +208,8 @@ |
209 | 209 | .get_library = get_library,
|
210 | 210 | .get_library_ext = get_library_ext,
|
211 | 211 | .release_library = release_library,
|
212 | | - .release_library_ext = release_library_ext
|
| 212 | + .release_library_ext = release_library_ext,
|
| 213 | +#ifdef HAVE_STORAGE
|
| 214 | + .fat_enable_flushing = fat_enable_flushing
|
| 215 | +#endif
|
213 | 216 | };
|
Index: emcore/trunk/usb/usb.c |
— | — | @@ -628,6 +628,7 @@ |
629 | 629 | case 50: // DISK_MOUNT
|
630 | 630 | case 51: // DISK_UNMOUNT
|
631 | 631 | #endif
|
| 632 | + case 58: // FAT_ENABLE_FLUSHING
|
632 | 633 | if (!set_dbgaction(DBGACTION_STORAGE, 0))
|
633 | 634 | memcpy(dbgasyncsendbuf, dbgrecvbuf, sizeof(dbgasyncsendbuf));
|
634 | 635 | break;
|
— | — | @@ -945,6 +946,11 @@ |
946 | 947 | usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
|
947 | 948 | break;
|
948 | 949 | #endif
|
| 950 | + case 58: // FAT_ENABLE_FLUSHING
|
| 951 | + dbgasyncsendbuf[0] = 1;
|
| 952 | + fat_enable_flushing((bool)(dbgasyncsendbuf[1]));
|
| 953 | + usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
|
| 954 | + break;
|
949 | 955 | }
|
950 | 956 | break;
|
951 | 957 | #endif
|
Index: emcore/trunk/fat.c |
— | — | @@ -179,6 +179,7 @@ |
180 | 180 |
|
181 | 181 | static struct bpb fat_bpbs[NUM_VOLUMES]; /* mounted partition info */
|
182 | 182 | static bool initialized = false;
|
| 183 | +static bool flush_fat_disabled = false;
|
183 | 184 |
|
184 | 185 | static int update_fsinfo(IF_MV_NONVOID(struct bpb* fat_bpb));
|
185 | 186 | static int flush_fat(IF_MV_NONVOID(struct bpb* fat_bpb));
|
— | — | @@ -1024,6 +1025,11 @@ |
1025 | 1026 | int i;
|
1026 | 1027 | int rc;
|
1027 | 1028 | unsigned char *sec;
|
| 1029 | + if (flush_fat_disabled)
|
| 1030 | + {
|
| 1031 | + DEBUGF("flush_fat() skipped");
|
| 1032 | + return 0;
|
| 1033 | + }
|
1028 | 1034 | DEBUGF("flush_fat()");
|
1029 | 1035 |
|
1030 | 1036 | mutex_lock(&cache_mutex, TIMEOUT_BLOCK);
|
— | — | @@ -2559,3 +2565,9 @@ |
2560 | 2566 | return (volume<NUM_VOLUMES && fat_bpbs[volume].mounted);
|
2561 | 2567 | }
|
2562 | 2568 | #endif
|
| 2569 | +
|
| 2570 | +void fat_enable_flushing(bool state)
|
| 2571 | +{
|
| 2572 | + flush_fat_disabled = !state;
|
| 2573 | + if (state) flush_fat();
|
| 2574 | +}
|
Index: emcore/trunk/fat.h |
— | — | @@ -132,6 +132,7 @@ |
133 | 133 | extern bool fat_ismounted(int volume);
|
134 | 134 | extern void* fat_get_sector_buffer(void);
|
135 | 135 | extern void fat_release_sector_buffer(void);
|
| 136 | +extern void fat_enable_flushing(bool state);
|
136 | 137 |
|
137 | 138 | #endif
|
138 | 139 | #endif
|