comparison packages/fs/rom/current/src/romfs.c @ 208:e0c0827131d1 ecos

Merge from eCos master repository on 2002-05-20-20:11:54-BST
author jlarmour
date Mon, 20 May 2002 22:19:26 +0000
parents b939e9cada46
children d2c90368aeef
comparison
equal deleted inserted replaced
207:74c807ddde34 208:e0c0827131d1
3 // romfs.c 3 // romfs.c
4 // 4 //
5 // ROM file system 5 // ROM file system
6 // 6 //
7 //========================================================================== 7 //==========================================================================
8 //####COPYRIGHTBEGIN#### 8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // 9 // -------------------------------------------
10 // ------------------------------------------- 10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // The contents of this file are subject to the Red Hat eCos Public License 11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12 // Version 1.1 (the "License"); you may not use this file except in 12 //
13 // compliance with the License. You may obtain a copy of the License at 13 // eCos is free software; you can redistribute it and/or modify it under
14 // http://www.redhat.com/ 14 // the terms of the GNU General Public License as published by the Free
15 // 15 // Software Foundation; either version 2 or (at your option) any later version.
16 // Software distributed under the License is distributed on an "AS IS" 16 //
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 17 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18 // License for the specific language governing rights and limitations under 18 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 // the License. 19 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 // 20 // for more details.
21 // The Original Code is eCos - Embedded Configurable Operating System, 21 //
22 // released September 30, 1998. 22 // You should have received a copy of the GNU General Public License along
23 // 23 // with eCos; if not, write to the Free Software Foundation, Inc.,
24 // The Initial Developer of the Original Code is Red Hat. 24 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25 // Portions created by Red Hat are 25 //
26 // Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc. 26 // As a special exception, if other files instantiate templates or use macros
27 // All Rights Reserved. 27 // or inline functions from this file, or you compile this file and link it
28 // ------------------------------------------- 28 // with other works to produce a work based on this file, this file does not
29 // 29 // by itself cause the resulting work to be covered by the GNU General Public
30 //####COPYRIGHTEND#### 30 // License. However the source code for this file must still be made available
31 // in accordance with section (3) of the GNU General Public License.
32 //
33 // This exception does not invalidate any other reasons why a work based on
34 // this file might be covered by the GNU General Public License.
35 //
36 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37 // at http://sources.redhat.com/ecos/ecos-license
38 // -------------------------------------------
39 //####ECOSGPLCOPYRIGHTEND####
31 //========================================================================== 40 //==========================================================================
32 //#####DESCRIPTIONBEGIN#### 41 //#####DESCRIPTIONBEGIN####
33 // 42 //
34 // Author(s): nickg 43 // Author(s): nickg
35 // Contributors: nickg, richard.panton@3glab.com 44 // Contributors: nickg, richard.panton@3glab.com
97 // ------------ 106 // ------------
98 // 107 //
99 // Each file has its data stored in a single contiguous memory block 108 // Each file has its data stored in a single contiguous memory block
100 // referenced by the offset in the node. 109 // referenced by the offset in the node.
101 // 110 //
102 // [ The start of the data for each node is aligned to a boundary - a four ]
103 // [ byte boundary in the case of data files, or a PAGESIZE boudary in the ]
104 // [ case of executable files. This alignment is enforced by the mk_romfs ]
105 // [ program, and has no effect on the code contained in this file. ]
106 //
107 //========================================================================== 111 //==========================================================================
108 112
109 #include <pkgconf/system.h> 113 #include <pkgconf/system.h>
110 #include <pkgconf/hal.h> 114 #include <pkgconf/hal.h>
111 #include <pkgconf/kernel.h> 115 #include <pkgconf/kernel.h>
132 136
133 #include <cyg/kernel/kapi.h> 137 #include <cyg/kernel/kapi.h>
134 #include <cyg/infra/diag.h> 138 #include <cyg/infra/diag.h>
135 139
136 //========================================================================== 140 //==========================================================================
137 // Alignment values. Must tie in with the similar defintions given in mk_romfs.c
138 #define ROMFS_DIRENT_ALIGNMENT 32
139
140 // Eventually we want to eXecute In Place from the ROM in a protected 141 // Eventually we want to eXecute In Place from the ROM in a protected
141 // environment, so we'll need executables to be aligned to a boundary 142 // environment, so we'll need executables to be aligned to a boundary
142 // suitable for MMU protection. A suitable boundary would be the 4k 143 // suitable for MMU protection. A suitable boundary would be the 4k
143 // boundary in all the CPU architectures I am currently aware of. 144 // boundary in all the CPU architectures I am currently aware of.
144 145
392 393
393 err = findbuffer_node( disk, dir, pos, &buf, &size ); 394 err = findbuffer_node( disk, dir, pos, &buf, &size );
394 if( err != ENOERR || size == 0) 395 if( err != ENOERR || size == 0)
395 return NULL; 396 return NULL;
396 397
397 if ( (int)buf & (ROMFS_DIRENT_ALIGNMENT-1) )
398 return NULL;
399
400 d = (romfs_dirent *)buf; 398 d = (romfs_dirent *)buf;
401 399
402 // Is this the directory entry we're looking for? 400 // Is this the directory entry we're looking for?
403 if ( match( d->name, name, namelen ) ) 401 if ( match( d->name, name, namelen ) )
404 return d; 402 return d;