Changeset 585:b8ac88d76805

Show
Ignore:
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:
6 removed
5 modified

Legend:

Unmodified
Added
Removed
  • nxos/base/fs.c

    r576 r585  
    2323#define FS_FILE_METADATA_SIZE 10 
    2424 
    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. */ 
    2629#define FS_FILE_METADATA_BYTES (FS_FILE_METADATA_SIZE * sizeof(U32)) 
    2730 
     31/** Mask to use on the first metadata U32 to get the file origin marker value. */ 
    2832#define FS_FILE_ORIGIN_MASK 0xFF000000 
     33 
     34/** Mask to use on the first metadata U32 to get the file permissions. */ 
    2935#define FS_FILE_PERMS_MASK 0x00F00000 
     36 
     37/** Mask to use on the first metadata U32 to get the file size. */ 
    3038#define FS_FILE_SIZE_MASK 0x000FFFFF 
    3139 
     
    3341#define FS_FILE_PERM_MASK_EXECUTABLE (1 << 1) 
    3442 
    35 #define FS_FILENAME_OFFSET 2 
    36  
    37 /* U32 <-> char conversion union for filenames. */ 
     43/** U32 <-> char conversion union for filenames. */ 
    3844union U32tochar { 
    3945  char chars[FS_FILENAME_LENGTH]; 
     
    303309static fs_err_t nx_fs_init_fd(U32 origin, fs_fd_t fd) { 
    304310  volatile U32 *metadata = &(FLASH_BASE_PTR[origin*EFC_PAGE_WORDS]); 
     311  union U32tochar nameconv; 
    305312  fs_file_t *file; 
    306313 
     
    308315  NX_ASSERT(file != NULL); 
    309316 
     317  memcpy(nameconv.integers, 
     318         (void *)(metadata + FS_FILENAME_OFFSET), 
     319         FS_FILENAME_LENGTH); 
     320 
    310321  file->origin = origin; 
     322  memcpy(file->name, nameconv.chars, MIN(strlen(nameconv.chars), 31)); 
    311323  file->size = nx_fs_get_file_size_from_metadata(metadata); 
    312324  file->perms = nx_fs_get_file_perms_from_metadata(metadata); 
     
    678690} 
    679691 
    680 void nx_fs_get_occupation(U16 *files, U32 *used, U32 *free_pages, 
     692void nx_fs_get_occupation(U32 *files, U32 *used, U32 *free_pages, 
    681693                          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 
    682716  if (files) { 
     717    *files = _files; 
    683718  } 
    684719 
    685720  if (used) { 
     721    *used = _used; 
    686722  } 
    687723 
    688724  if (free_pages) { 
     725    *free_pages = _free_pages; 
    689726  } 
    690727 
    691728  if (wasted) { 
     729    *wasted = _wasted; 
    692730  } 
    693731} 
  • nxos/base/fs.c

    r582 r585  
    1717#include "base/drivers/_efc.h" 
    1818 
    19 /** Magic marker. */ 
     19/* Magic marker. */ 
    2020#define FS_FILE_ORIGIN_MARKER 0x42 
    2121 
    22 /** File metadata size, in U32s. */ 
     22/* File metadata size, in U32s. */ 
    2323#define FS_FILE_METADATA_SIZE 10 
    2424 
     
    4747}; 
    4848 
    49 /** FD-set. */ 
     49/* FD-set. */ 
    5050static fs_file_t fdset[FS_MAX_OPENED_FILES]; 
    5151 
     
    731731} 
    732732 
    733 /** Defrag functions. */ 
     733/* Defrag functions. */ 
    734734 
    735735fs_err_t nx_fs_defrag_simple(void) { 
  • nxos/base/fs.h

    r577 r585  
    2222/*@{*/ 
    2323 
    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 */ 
    2537/*@{*/ 
    2638 
     
    187199 * @param wasted The bytes lost by files page aligment. 
    188200 */ 
    189 void nx_fs_get_occupation(U16 *files, U32 *used, U32 *free_pages, 
     201void nx_fs_get_occupation(U32 *files, U32 *used, U32 *free_pages, 
    190202                          U32 *wasted); 
    191203 
  • nxos/base/fs.h

    r582 r585  
    11/** @file fs.h 
    2  *  @brief Flash file system 
     2 *  @brief Flash file system. 
    33 * 
    44 * A flash-friendly file system for the NXT on-board flash memory. 
  • nxos/base/lib/rcmd/rcmd.h

    r583 r585  
    33 */ 
    44 
    5 /* Copyright (c) 2007-2008 the NxOS developers 
     5/* Copyright (c) 2007,2008 the NxOS developers 
    66 * 
    77 * See AUTHORS for a full list of the developers. 
     
    1919/*@{*/ 
    2020 
    21 /** @defgroup rcmd Remote robot command library 
     21/** @defgroup rcmd Robot remote control 
    2222 * 
    2323 * The remote robot command library provides a small command parsing and