📄 filesystem.lst
字号:
235:io/filesystem.c **** dataflash_copy_page_to_buffer(tmp, 0);
236:io/filesystem.c ****
237:io/filesystem.c **** //get bytes used inside this block:
238:io/filesystem.c **** count = dataflash_read_buffer(FILESYSTEM_FILE_BLOCK_USAGE,0)+1;
239:io/filesystem.c ****
240:io/filesystem.c **** //dump block:
241:io/filesystem.c **** unsigned int i=0;
242:io/filesystem.c **** while (count > 0){
243:io/filesystem.c **** softuart_putc(dataflash_read_buffer(i,0));
244:io/filesystem.c **** count--;
245:io/filesystem.c **** i++;
246:io/filesystem.c **** }
247:io/filesystem.c ****
248:io/filesystem.c **** //calc next block:
249:io/filesystem.c **** tmp = dataflash_read_buffer(FILESYSTEM_FILE_NEXT_HI, 0)<<8;
250:io/filesystem.c **** tmp |= dataflash_read_buffer(FILESYSTEM_FILE_NEXT_LO, 0);
251:io/filesystem.c ****
252:io/filesystem.c **** //tmp should be zero if this is the last block. but we have a flag for last block, too:
253:io/filesystem.c **** if (dataflash_read_buffer(FILESYSTEM_FILE_BLOCKTAG,0) == 0xEE)
254:io/filesystem.c **** tmp = 0x0000; //last block!
255:io/filesystem.c **** }
256:io/filesystem.c **** #if FILESYSTEM_DEBUG
257:io/filesystem.c **** softuart_puts_progmem("FS : dump done.");
258:io/filesystem.c **** softuart_putnewline();
259:io/filesystem.c **** #endif
260:io/filesystem.c ****
261:io/filesystem.c **** }*/
262:io/filesystem.c ****
263:io/filesystem.c **** //search for given filename [8.3]
264:io/filesystem.c **** //return: 0 if not found, otherwise the file id
265:io/filesystem.c **** unsigned int filesystem_search_file(unsigned char *filename, unsigned char *filename_ext){
266:io/filesystem.c **** unsigned int tmp;
267:io/filesystem.c **** unsigned char x;
268:io/filesystem.c **** unsigned char i,j;
269:io/filesystem.c **** unsigned char found;
270:io/filesystem.c ****
271:io/filesystem.c **** //make file extension lowercase !!
272:io/filesystem.c **** for(unsigned char i=0; i<3 && filename_ext[i] != 0; i++){
273:io/filesystem.c **** if ((filename_ext[i] >= 'A') && (filename_ext[i] <= 'Z'))
274:io/filesystem.c **** filename_ext[i] = filename_ext[i] - 'A' + 'a';
275:io/filesystem.c **** }
276:io/filesystem.c ****
277:io/filesystem.c ****
278:io/filesystem.c **** #if FILESYSTEM_DEBUG
279:io/filesystem.c **** softuart_puts_progmem("FS : search file <");
280:io/filesystem.c **** x=0;
281:io/filesystem.c **** while((x<8) && filename[x])
282:io/filesystem.c **** softuart_putc(filename[x++]);
283:io/filesystem.c **** softuart_putc('>');
284:io/filesystem.c **** softuart_putc('<');
285:io/filesystem.c **** x=0;
286:io/filesystem.c **** while((x<3) && filename_ext[x])
287:io/filesystem.c **** softuart_putc(filename_ext[x++]);
288:io/filesystem.c **** softuart_puts_progmem("> ");
289:io/filesystem.c **** #endif
290:io/filesystem.c ****
291:io/filesystem.c **** //search all filesystem table entries:
292:io/filesystem.c **** for(i=0; i<FILESYSTEM_TABLE_SIZE; i++){
293:io/filesystem.c **** //copy page i to dataflash buffer 0
294:io/filesystem.c **** dataflash_copy_page_to_buffer(i, 0);
295:io/filesystem.c ****
296:io/filesystem.c **** //now read 11 filesystem entries:
297:io/filesystem.c **** for(j=0; j<11; j++){
298:io/filesystem.c **** //extract id
299:io/filesystem.c **** tmp = dataflash_read_buffer(j*24 + FILESYSTEM_FTABLE_ID_HI, 0)<<8;
300:io/filesystem.c **** tmp |= dataflash_read_buffer(j*24 + FILESYSTEM_FTABLE_ID_LO, 0);
301:io/filesystem.c ****
302:io/filesystem.c **** //only check valid files:
303:io/filesystem.c **** if (tmp != 0){
304:io/filesystem.c **** //check if first char equals, if true -> compare the rest
305:io/filesystem.c **** if (filename[0] == dataflash_read_buffer(j*24+FILESYSTEM_FTABLE_FILENAME_START,0)){
306:io/filesystem.c **** //yes, first char matches! -> compare
307:io/filesystem.c **** found = 1;
308:io/filesystem.c **** //check filename
309:io/filesystem.c **** for(x=1; x<8; x++){
310:io/filesystem.c **** //if char does not match -> found = 0
311:io/filesystem.c **** if (filename[x] != dataflash_read_buffer(j*24+FILESYSTEM_FTABLE_FILENAME_START + x,0))
312:io/filesystem.c **** found = 0;
313:io/filesystem.c **** //end of string -> break
314:io/filesystem.c **** if (filename[x] == 0)
315:io/filesystem.c **** break;
316:io/filesystem.c **** }
317:io/filesystem.c ****
318:io/filesystem.c **** //check extension (IS ALWAYS 3 CHARS !!)
319:io/filesystem.c **** for(x=0; x<3; x++){
320:io/filesystem.c **** if (filename_ext[x] != dataflash_read_buffer(j*24+FILESYSTEM_FTABLE_FILENAME_START + 8 + x,0)
321:io/filesystem.c **** found = 0;
322:io/filesystem.c **** }
323:io/filesystem.c ****
324:io/filesystem.c **** if (found == 1){
325:io/filesystem.c **** //we got it -> return file id
326:io/filesystem.c **** #if FILESYSTEM_DEBUG
327:io/filesystem.c **** softuart_puts_progmem(" found !\r\n");
328:io/filesystem.c **** #endif
329:io/filesystem.c **** return tmp;
330:io/filesystem.c **** }
331:io/filesystem.c **** }
332:io/filesystem.c **** }
333:io/filesystem.c **** }
334:io/filesystem.c **** }
335:io/filesystem.c ****
336:io/filesystem.c **** //not found -> return 0
337:io/filesystem.c **** #if FILESYSTEM_DEBUG
338:io/filesystem.c **** softuart_puts_progmem(" not found !\r\n");
339:io/filesystem.c **** #endif
340:io/filesystem.c **** return 0;
341:io/filesystem.c **** }
342:io/filesystem.c ****
343:io/filesystem.c **** //erase filesystem !!!
344:io/filesystem.c **** //FIXME: use dataflash erase instead !
345:io/filesystem.c **** void filesystem_format(){
121 B1
122 .LM0:
123 .LFBB1:
124 0000 CF93 push r28
125 0002 DF93 push r29
126 /* prologue: function */
127 /* frame size = 0 */
346:io/filesystem.c **** please wait (takes a long time) [");
347:io/filesystem.c **** #endif
348:io/filesystem.c **** //copy page 0 to dataflash buffer 0
349:io/filesystem.c **** dataflash_copy_page_to_buffer(0, 0); //??? remove this, not neccessary!
350:io/filesystem.c ****
351:io/filesystem.c **** //clear buffer
352:io/filesystem.c **** for(i=0; i<256+8; i++)
128 68,0,352,.LM1-.LFBB1
129 .LM1:
130 0004 80E0 ldi r24,lo8(0)
131 0006 90E0 ldi r25,hi8(0)
132 0008 60E0 ldi r22,lo8(0)
133 000a 0E94 0000 call dataflash_copy_page_to_buffer
134 000e C0E0 ldi r28,lo8(0)
135 0010 D0E0 ldi r29,hi8(0)
136 .L2:
353:io/filesystem.c **** flash_write_to_page_buffer(i,0,0);
354:io/filesystem.c ****
355:io/filesystem.c **** //copy buffer to all fs table sectors:
356:io/filesystem.c **** for(i=0; i<FILESYSTEM_BLOCK_COUNT; i++){
137 8,0,356,.LM2-.LFBB1
138 .LM2:
139 0012 CE01 movw r24,r28
140 0014 60E0 ldi r22,lo8(0)
141 0016 40E0 ldi r20,lo8(0)
142 0018 0E94 0000 call dataflash_write_to_page_buffer
144 .LM3:
145 001c 2196 adiw r28,1
146 001e 81E0 ldi r24,hi8(264)
147 0020 C830 cpi r28,lo8(264)
148 0022 D807 cpc r29,r24
149 0024 01F4 brne .L2
150 0026 C0E0 ldi r28,lo8(0)
151 0028 D0E0 ldi r29,hi8(0)
152 .L3:
357:io/filesystem.c **** store cleared buffer on flash:
358:io/filesystem.c **** dataflash_copy_buffer_to_page(i,0);
359:io/filesystem.c **** #if FILESYSTEM_DEBUG
360:io/filesystem.c **** softuart_putc('.');
361:io/filesystem.c **** #endif
153 ,.LM4-.LFBB1
154 .LM4:
155 002a CE01 movw r24,r28
156 002c 60E0 ldi r22,lo8(0)
157 002e 0E94 0000 call dataflash_copy_buffer_to_page
159 .LM5:
160 0032 2196 adiw r28,1
161 0034 88E0 ldi r24,hi8(2048)
162 0036 C030 cpi r28,lo8(2048)
163 0038 D807 cpc r29,r24
164 003a 01F4 brne .L3
165 /* epilogue start */
362:io/filesystem.c **** if FILESYSTEM_DEBUG
363:io/filesystem.c **** softuart_puts_progmem("] done");
364:io/filesystem.c **** softuart_putnewline();
365:io/filesystem.c **** #endif
366:io/filesystem.c ****
367:io/filesystem.c **** }
368:io/filesystem.c ****
369:io/filesystem.c **** //list files in filesystem:
370:io/filesystem.c **** /*void filesystem_list_files(){
371:io/filesystem.c **** unsigned int tmp,tmp2;
166 371,.LM6-.LFBB1
167 .LM6:
168 003c DF91 pop r29
169 003e CF91 pop r28
170 0040 0895 ret
175 .Lscope1:
177 .global filesystem_allocate_block
179 filesystem_allocate_block:
372:io/filesystem.c **** char i,j,k;
373:io/filesystem.c ****
374:io/filesystem.c **** #if FILESYSTEM_DEBUG
375:io/filesystem.c **** softuart_putnewline();
376:io/filesystem.c **** softuart_puts_progmem(" <fid> <start> <size> <filename>");
377:io/filesystem.c **** softuart_putnewline();
378:io/filesystem.c **** softuart_puts_progmem("---------------------------------------");
379:io/filesystem.c **** softuart_putnewline();
380:io/filesystem.c **** #endif
381:io/filesystem.c ****
382:io/filesystem.c **** //search all filesystem table entries:
383:io/filesystem.c **** for(i=0; i<FILESYSTEM_TABLE_SIZE; i++){
384:io/filesystem.c **** //copy page i to dataflash buffer 0
385:io/filesystem.c **** dataflash_copy_page_to_buffer(i, 0);
386:io/filesystem.c ****
387:io/filesystem.c **** //now read 11 filesystem entries:
388:io/filesystem.c **** for(j=0; j<11; j++){
389:io/filesystem.c **** //check if there is already a file with our id:
390:io/filesystem.c **** tmp = dataflash_read_buffer(j*24 + FILESYSTEM_FTABLE_ID_HI, 0)<<8;
391:io/filesystem.c **** tmp |= dataflash_read_buffer(j*24 + FILESYSTEM_FTABLE_ID_LO, 0);
392:io/filesystem.c ****
393:io/filesystem.c **** if (tmp != 0){
394:io/filesystem.c **** //print all:
395:io/filesystem.c **** //for(tmp2=0; tmp2<24; tmp2++)
396:io/filesystem.c **** // rprintf("%x ",dataflash_read_buffer(j*24+tmp2,0));
397:io/filesystem.c **** //rprintf("\r\n");
398:io/filesystem.c ****
399:io/filesystem.c **** //this is a active file -> print
400:io/filesystem.c **** #if FILESYSTEM_DEBUG
401:io/filesystem.c **** softuart_putc(' ');
402:io/filesystem.c **** softuart_put_uint16(tmp);
403:io/filesystem.c ****
404:io/filesystem.c **** //print start/end sector:
405:io/filesystem.c **** tmp = dataflash_read_buffer(j*24 + FILESYSTEM_FTABLE_BLOCK_START_HI, 0);
406:io/filesystem.c **** tmp = tmp<<8;
407:io/filesystem.c **** tmp += dataflash_read_buffer(j*24 + FILESYSTEM_FTABLE_BLOCK_START_LO, 0);
408:io/filesystem.c **** tmp2 = dataflash_read_buffer(j*24 + FILESYSTEM_FTABLE_BLOCK_COUNT_HI, 0);
409:io/filesystem.c **** tmp2 = tmp2<<8;
410:io/filesystem.c **** tmp2 += dataflash_read_buffer(j*24 + FILESYSTEM_FTABLE_BLOCK_COUNT_LO, 0);
411:io/filesystem.c ****
412:io/filesystem.c **** softuart_putc(' ');
413:io/filesystem.c **** softuart_putc(' ');
414:io/filesystem.c **** softuart_put_uint16(tmp);
415:io/filesystem.c **** softuart_puts_progmem(" / ");
416:io/filesystem.c **** softuart_put_uint16(tmp2);
417:io/filesystem.c ****
418:io/filesystem.c **** softuart_puts_progmem(" ./");
419:io/filesystem.c ****
420:io/filesystem.c **** unsigned char c;
421:io/filesystem.c **** for (k=0; k<8; k++){
422:io/filesystem.c **** c = dataflash_read_buffer(j*24 + FILESYSTEM_FTABLE_FILENAME_START + k, 0);
423:io/filesystem.c **** if (c)
424:io/filesystem.c **** softuart_putc(c);
425:io/filesystem.c **** else
426:io/filesystem.c **** break;
427:io/filesystem.c **** }
428:io/filesystem.c **** softuart_putc('.');
429:io/filesystem.c **** for (k=0; k<3; k++){
430:io/filesystem.c **** c = dataflash_read_buffer(j*24 + FILESYSTEM_FTABLE_FILENAME_START + 8 +k, 0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -