Changeset 585:b8ac88d76805
- Timestamp:
- 06/07/08 19:14:14 (7 months ago)
- Author:
- David Anderson <dave@…>
- Parents:
- 580:2e24b11dbe5a (diff), 584:8df35f33dbdd (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
- Branch:
- default
- Message:
-
Merge changes from crew/sam
- Location:
- nxos/base
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r576
|
r585
|
|
| 23 | 23 | #define FS_FILE_METADATA_SIZE 10 |
| 24 | 24 | |
| 25 | | /* File metadata size, in bytes. */ |
| | 25 | /** Filename offset (in U32s) in the metadata. */ |
| | 26 | #define FS_FILENAME_OFFSET 2 |
| | 27 | |
| | 28 | /** File metadata size, in bytes. */ |
| 26 | 29 | #define FS_FILE_METADATA_BYTES (FS_FILE_METADATA_SIZE * sizeof(U32)) |
| 27 | 30 | |
| | 31 | /** Mask to use on the first metadata U32 to get the file origin marker value. */ |
| 28 | 32 | #define FS_FILE_ORIGIN_MASK 0xFF000000 |
| | 33 | |
| | 34 | /** Mask to use on the first metadata U32 to get the file permissions. */ |
| 29 | 35 | #define FS_FILE_PERMS_MASK 0x00F00000 |
| | 36 | |
| | 37 | /** Mask to use on the first metadata U32 to get the file size. */ |
| 30 | 38 | #define FS_FILE_SIZE_MASK 0x000FFFFF |
| 31 | 39 | |
| … |
… |
|
| 33 | 41 | #define FS_FILE_PERM_MASK_EXECUTABLE (1 << 1) |
| 34 | 42 | |
| 35 | | #define FS_FILENAME_OFFSET 2 |
| 36 | | |
| 37 | | /* U32 <-> char conversion union for filenames. */ |
| | 43 | /** U32 <-> char conversion union for filenames. */ |
| 38 | 44 | union U32tochar { |
| 39 | 45 | char chars[FS_FILENAME_LENGTH]; |
| … |
… |
|
| 303 | 309 | static fs_err_t nx_fs_init_fd(U32 origin, fs_fd_t fd) { |
| 304 | 310 | volatile U32 *metadata = &(FLASH_BASE_PTR[origin*EFC_PAGE_WORDS]); |
| | 311 | union U32tochar nameconv; |
| 305 | 312 | fs_file_t *file; |
| 306 | 313 | |
| … |
… |
|
| 308 | 315 | NX_ASSERT(file != NULL); |
| 309 | 316 | |
| | 317 | memcpy(nameconv.integers, |
| | 318 | (void *)(metadata + FS_FILENAME_OFFSET), |
| | 319 | FS_FILENAME_LENGTH); |
| | 320 | |
| 310 | 321 | file->origin = origin; |
| | 322 | memcpy(file->name, nameconv.chars, MIN(strlen(nameconv.chars), 31)); |
| 311 | 323 | file->size = nx_fs_get_file_size_from_metadata(metadata); |
| 312 | 324 | file->perms = nx_fs_get_file_perms_from_metadata(metadata); |
| … |
… |
|
| 678 | 690 | } |
| 679 | 691 | |
| 680 | | void nx_fs_get_occupation(U16 *files, U32 *used, U32 *free_pages, |
| | 692 | void nx_fs_get_occupation(U32 *files, U32 *used, U32 *free_pages, |
| 681 | 693 | U32 *wasted) { |
| | 694 | U32 _files = 0, _used = 0, _free_pages = 0, _wasted = 0; |
| | 695 | U32 i; |
| | 696 | |
| | 697 | for (i=FS_PAGE_START; i<FS_PAGE_END; i++) { |
| | 698 | if (nx_fs_page_has_magic(i)) { |
| | 699 | volatile U32 *metadata = &(FLASH_BASE_PTR[i*EFC_PAGE_WORDS]); |
| | 700 | size_t size; |
| | 701 | U32 pages; |
| | 702 | |
| | 703 | size = nx_fs_get_file_size_from_metadata(metadata); |
| | 704 | pages = nx_fs_get_file_page_count(size); |
| | 705 | |
| | 706 | _files++; |
| | 707 | _used += size; |
| | 708 | _wasted += pages * EFC_PAGE_BYTES - size - FS_FILE_METADATA_BYTES; |
| | 709 | |
| | 710 | i += pages - 1; |
| | 711 | } else { |
| | 712 | _free_pages++; |
| | 713 | } |
| | 714 | } |
| | 715 | |
| 682 | 716 | if (files) { |
| | 717 | *files = _files; |
| 683 | 718 | } |
| 684 | 719 | |
| 685 | 720 | if (used) { |
| | 721 | *used = _used; |
| 686 | 722 | } |
| 687 | 723 | |
| 688 | 724 | if (free_pages) { |
| | 725 | *free_pages = _free_pages; |
| 689 | 726 | } |
| 690 | 727 | |
| 691 | 728 | if (wasted) { |
| | 729 | *wasted = _wasted; |
| 692 | 730 | } |
| 693 | 731 | } |
-
|
r582
|
r585
|
|
| 17 | 17 | #include "base/drivers/_efc.h" |
| 18 | 18 | |
| 19 | | /** Magic marker. */ |
| | 19 | /* Magic marker. */ |
| 20 | 20 | #define FS_FILE_ORIGIN_MARKER 0x42 |
| 21 | 21 | |
| 22 | | /** File metadata size, in U32s. */ |
| | 22 | /* File metadata size, in U32s. */ |
| 23 | 23 | #define FS_FILE_METADATA_SIZE 10 |
| 24 | 24 | |
| … |
… |
|
| 47 | 47 | }; |
| 48 | 48 | |
| 49 | | /** FD-set. */ |
| | 49 | /* FD-set. */ |
| 50 | 50 | static fs_file_t fdset[FS_MAX_OPENED_FILES]; |
| 51 | 51 | |
| … |
… |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | | /** Defrag functions. */ |
| | 733 | /* Defrag functions. */ |
| 734 | 734 | |
| 735 | 735 | fs_err_t nx_fs_defrag_simple(void) { |
-
|
r577
|
r585
|
|
| 22 | 22 | /*@{*/ |
| 23 | 23 | |
| 24 | | /** @defgroup fs Flash file system */ |
| | 24 | /** @defgroup fs Flash file system |
| | 25 | * |
| | 26 | * A flash-friendly file system for the NXT on-board flash memory. This is a very simple |
| | 27 | * file system implementation, allowing most of the basic features expected from a file |
| | 28 | * system: open(), read(), write(), seek(), flush() and close(). Note that reading and |
| | 29 | * writing use two different pointers. A seek() will move both of them. |
| | 30 | * |
| | 31 | * The file system also tries to minimize stress on the flash by progressively moving files |
| | 32 | * needing more space towards the end of the flash medium. This relocation process happens |
| | 33 | * automatically and may make one write operation rather costly (in terms of time). |
| | 34 | * |
| | 35 | * For more information, refer to the file system design document. |
| | 36 | */ |
| 25 | 37 | /*@{*/ |
| 26 | 38 | |
| … |
… |
|
| 187 | 199 | * @param wasted The bytes lost by files page aligment. |
| 188 | 200 | */ |
| 189 | | void nx_fs_get_occupation(U16 *files, U32 *used, U32 *free_pages, |
| | 201 | void nx_fs_get_occupation(U32 *files, U32 *used, U32 *free_pages, |
| 190 | 202 | U32 *wasted); |
| 191 | 203 | |
-
|
r582
|
r585
|
|
| 1 | 1 | /** @file fs.h |
| 2 | | * @brief Flash file system |
| | 2 | * @brief Flash file system. |
| 3 | 3 | * |
| 4 | 4 | * A flash-friendly file system for the NXT on-board flash memory. |
-
|
r583
|
r585
|
|
| 3 | 3 | */ |
| 4 | 4 | |
| 5 | | /* Copyright (c) 2007-2008 the NxOS developers |
| | 5 | /* Copyright (c) 2007,2008 the NxOS developers |
| 6 | 6 | * |
| 7 | 7 | * See AUTHORS for a full list of the developers. |
| … |
… |
|
| 19 | 19 | /*@{*/ |
| 20 | 20 | |
| 21 | | /** @defgroup rcmd Remote robot command library |
| | 21 | /** @defgroup rcmd Robot remote control |
| 22 | 22 | * |
| 23 | 23 | * The remote robot command library provides a small command parsing and |