URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
Compare Revisions
- This comparison shows the changes necessary to convert path
/or1k/trunk/ecos-2.0/packages/redboot/v2_0/include/fs
- from Rev 1254 to Rev 1765
- ↔ Reverse comparison
Rev 1254 → Rev 1765
/disk.h
0,0 → 1,173
//========================================================================== |
// |
// disk.h |
// |
// Stand-alone disk support for RedBoot |
// |
//========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//========================================================================== |
//#####DESCRIPTIONBEGIN#### |
// |
// Author(s): msalter |
// Contributors: msalter |
// Date: 2001-07-02 |
// Purpose: |
// Description: |
// |
// This code is part of RedBoot (tm). |
// |
//####DESCRIPTIONEND#### |
// |
//========================================================================== |
|
#ifndef CYGONCE_REDBOOT_DISK_H |
#define CYGONCE_REDBOOT_DISK_H |
|
#define SECTOR_SIZE 512 |
|
// Convenience macros to access disk/filesystem info which may |
// be stored in a fixed endian format. |
|
#define __SWAB16(x) \ |
((((x) & 0xFF) << 8) | (((x) >> 8) & 0xFF)) |
|
#define __SWAB32(x) \ |
((((x) & 0xff) << 24) | \ |
(((x) & 0xff00) << 8) | \ |
(((x) >> 8) & 0xff00) | \ |
(((x) >> 24) & 0xff)) |
|
#if (CYG_BYTEORDER == CYG_MSBFIRST) |
#define SWAB_LE16(x) __SWAB16(x) |
#define SWAB_LE32(x) __SWAB32(x) |
#define SWAB_BE16(x) (x) |
#define SWAB_BE32(x) (x) |
#else |
#define SWAB_LE16(x) (x) |
#define SWAB_LE32(x) (x) |
#define SWAB_BE16(x) __SWAB16(x) |
#define SWAB_BE32(x) __SWAB32(x) |
#endif |
|
struct partition; |
|
// filesystem interface |
typedef struct fs_funs { |
// Load a file into memory. |
void * (*open)(struct partition *p, const char *path); |
int (*read)(void *fp, char *buf, cyg_uint32 nbytes); |
} fs_funs_t; |
|
struct disk; |
|
typedef struct partition { |
struct disk *disk; |
fs_funs_t *funs; |
cyg_uint32 start_sector; // first sector in partition |
cyg_uint32 nr_sectors; // number of sectors in partition |
cyg_uint8 systype; // FAT12, FAT16, Linux, etc. |
cyg_uint8 bootflag; // not really used... |
} partition_t; |
|
// System types |
#define SYSTYPE_FAT12 0x01 |
#define SYSTYPE_FAT16_32M 0x04 |
#define SYSTYPE_EXTENDED 0x05 |
#define SYSTYPE_FAT16 0x06 |
#define SYSTYPE_LINUX_SWAP 0x82 |
#define SYSTYPE_LINUX 0x83 |
|
typedef struct disk_funs { |
int (*read)(struct disk *d, |
cyg_uint32 start_sector, |
cyg_uint32 *buf, |
cyg_uint8 nr_sectors); |
} disk_funs_t; |
|
|
typedef struct disk { |
disk_funs_t *funs; // Disk driver functions |
void *private; // Whatever is needed by disk functions |
cyg_uint32 nr_sectors; // Total disk size in sectors |
short kind; // IDE_HD, IDE_CDROM, SCSI_HD, etc |
short index; // index within specific kind |
partition_t partitions[CYGNUM_REDBOOT_MAX_PARTITIONS]; |
} disk_t; |
|
#define DISK_READ(d,s,p,n) ((d)->funs->read)((d),(s),(p),(n)) |
#define PARTITION_READ(part,s,p,n) \ |
DISK_READ((part)->disk, (s) + (part)->start_sector, (p), (n)) |
|
// Kinds of disks |
#define DISK_IDE_HD 1 |
#define DISK_IDE_CDROM 2 |
#define DISK_FLOPPY 3 |
|
// DOS partition table as laid out in the MBR |
// |
struct mbr_partition { |
cyg_uint8 boot_ind; // 0x80 == active |
cyg_uint8 head; |
cyg_uint8 sector; |
cyg_uint8 cyl; |
cyg_uint8 sys_ind; // partition type |
cyg_uint8 end_head; |
cyg_uint8 end_sector; |
cyg_uint8 end_cyl; |
cyg_uint8 start_sect[4]; // starting sector counting from 0 |
cyg_uint8 nr_sects[4]; // number of sectors in partition |
}; |
|
#define MBR_PTABLE_OFFSET 0x1be |
#define MBR_MAGIC_OFFSET 0x1fe |
#define MBR_MAGIC 0xaa55 |
|
// Add a disk to the disk table. |
// Return zero if no more room in table. |
// |
externC int disk_register(disk_t *disk); |
|
|
#define diskerr_badname -1 |
#define diskerr_partition -2 |
#define diskerr_open -3 |
#define diskerr_read -4 |
|
externC int disk_stream_open(connection_info_t *info, int *err); |
externC void disk_stream_close(int *err); |
externC int disk_stream_read(char *buf, int size, int *err); |
externC char *disk_error(int err); |
|
#endif // CYGONCE_REDBOOT_DISK_H |
/e2fs.h
0,0 → 1,199
//========================================================================== |
// |
// e2fs.h |
// |
// Second extended filesystem defines. |
// |
//========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//========================================================================== |
//#####DESCRIPTIONBEGIN#### |
// |
// Author(s): msalter |
// Contributors: msalter |
// Date: 2001-06-25 |
// Purpose: |
// Description: |
// |
// This code is part of RedBoot (tm). |
// |
//####DESCRIPTIONEND#### |
// |
//========================================================================== |
|
#ifndef CYGONCE_REDBOOT_E2FS_H |
#define CYGONCE_REDBOOT_E2FS_H |
|
// |
// Structure of the super block |
// |
struct e2fs_super_block { |
cyg_uint32 inodes_count; |
cyg_uint32 blocks_count; |
cyg_uint32 r_blocks_count; |
cyg_uint32 free_blocks_count; |
cyg_uint32 free_inodes_count; |
cyg_uint32 first_data_block; |
cyg_uint32 log_block_size; |
cyg_int32 log_frag_size; |
cyg_uint32 blocks_per_group; |
cyg_uint32 frags_per_group; |
cyg_uint32 inodes_per_group; |
cyg_uint32 mtime; |
cyg_uint32 wtime; |
cyg_uint16 mnt_count; |
cyg_int16 max_mnt_count; |
cyg_uint16 magic; |
cyg_uint16 state; |
cyg_uint16 errors; |
cyg_uint16 minor_rev_level; |
cyg_uint32 lastcheck; |
cyg_uint32 checkinterval; |
cyg_uint32 creator_os; |
cyg_uint32 rev_level; |
cyg_uint16 def_resuid; |
cyg_uint16 def_resgid; |
}; |
|
#define E2FS_PRE_02B_MAGIC 0xEF51 |
#define E2FS_SUPER_MAGIC 0xEF53 |
|
#define E2FS_PTRS_PER_BLOCK(e) ((e)->blocksize / sizeof(cyg_uint32)) |
|
#define E2FS_BLOCK_SIZE(s) (E2FS_MIN_BLOCK_SIZE << SWAB_LE32((s)->log_block_size)) |
#define E2FS_ADDR_PER_BLOCK(s) (E2FS_BLOCK_SIZE(s) / sizeof(unsigned int)) |
#define E2FS_BLOCK_SIZE_BITS(s) (SWAB_LE32((s)->log_block_size) + 10) |
|
#define E2FS_NR_DIR_BLOCKS 12 |
|
#define E2FS_IND_BLOCK E2FS_NR_DIR_BLOCKS |
#define E2FS_DIND_BLOCK (E2FS_IND_BLOCK + 1) |
#define E2FS_TIND_BLOCK (E2FS_DIND_BLOCK + 1) |
|
#define E2FS_N_BLOCKS (E2FS_TIND_BLOCK + 1) |
|
|
// Structure of an inode on the disk |
// |
typedef struct e2fs_inode { |
cyg_uint16 mode; |
cyg_uint16 uid; |
cyg_uint32 size; |
cyg_uint32 atime; |
cyg_uint32 ctime; |
cyg_uint32 mtime; |
cyg_uint32 dtime; |
cyg_uint16 gid; |
cyg_uint16 links_count; |
cyg_uint32 blocks; |
cyg_uint32 flags; |
cyg_uint32 reserved1; |
cyg_uint32 block[E2FS_N_BLOCKS]; |
cyg_uint32 version; |
cyg_uint32 file_acl; |
cyg_uint32 dir_acl; |
cyg_uint32 faddr; |
cyg_uint8 frag; |
cyg_uint8 fsize; |
cyg_uint16 pad1; |
cyg_uint32 reserved2[2]; |
} e2fs_inode_t; |
|
|
#define E2FS_INODES_PER_BLOCK(e) ((e)->blocksize / sizeof (struct e2fs_inode)) |
|
#define E2FS_MIN_BLOCK_SIZE 1024 |
#define E2FS_MAX_BLOCK_SIZE 4096 |
|
// Special inode numbers |
// |
#define E2FS_BAD_INO 1 |
#define E2FS_ROOT_INO 2 |
|
typedef struct e2fs_dir_entry { |
cyg_uint32 inode; |
cyg_uint16 reclen; |
cyg_uint8 namelen; |
cyg_uint8 filetype; |
char name[2]; |
} e2fs_dir_entry_t; |
|
#define E2FS_FTYPE_UNKNOWN 0 |
#define E2FS_FTYPE_REG_FILE 1 |
#define E2FS_FTYPE_DIR 2 |
#define E2FS_FTYPE_CHRDEV 3 |
#define E2FS_FTYPE_BLKDEV 4 |
#define E2FS_FTYPE_FIFO 5 |
#define E2FS_FTYPE_SOCK 6 |
#define E2FS_FTYPE_SYMLINK 7 |
|
typedef struct e2fs_group |
{ |
cyg_uint32 block_bitmap; // blocks bitmap block |
cyg_uint32 inode_bitmap; // inodes bitmap block |
cyg_uint32 inode_table; // inodes table block |
cyg_uint16 free_blocks_count; |
cyg_uint16 free_inodes_count; |
cyg_uint16 used_dirs_count; |
cyg_uint16 pad; |
cyg_uint32 reserved[3]; |
} e2fs_group_t; |
|
#define E2FS_BLOCKS_PER_GROUP(s) (SWAB_LE32((s)->blocks_per_group)) |
#define E2FS_INODES_PER_GROUP(s) (SWAB_LE32((s)->inodes_per_group)) |
|
#define E2FS_GDESC_PER_BLOCK(e) ((e)->blocksize / sizeof (struct e2fs_e2fs_group_desc)) |
#define E2FS_GDESC_PER_SECTOR (SECTOR_SIZE/sizeof(e2fs_group_t)) |
#define E2FS_GDESC_CACHE_SIZE (E2FS_GDESC_PER_SECTOR * 1) |
#define E2FS_GDESC_PER_SECTOR (SECTOR_SIZE/sizeof(e2fs_group_t)) |
|
typedef struct e2fs_desc { |
partition_t *part; // partition holding this filesystem |
cyg_uint32 blocksize; // fs blocksize |
cyg_uint32 ngroups; // number of groups in fs |
cyg_uint32 blocks_per_group; |
cyg_uint32 inodes_per_group; |
cyg_uint32 gdesc_block; // block nr of group descriptors |
cyg_int32 gdesc_first; // which gdesc is first in cache |
e2fs_group_t gdesc_cache[E2FS_GDESC_CACHE_SIZE]; |
cyg_uint32 nr_ind_blocks; |
cyg_uint32 nr_dind_blocks; |
cyg_uint32 nr_tind_blocks; |
} e2fs_desc_t; |
|
#define E2FS_BLOCK_TO_SECTOR(e,b) ((b) * ((e)->blocksize / SECTOR_SIZE)) |
|
extern fs_funs_t redboot_e2fs_funs; |
|
#endif // CYGONCE_REDBOOT_E2FS_H |
/ide.h
0,0 → 1,104
//========================================================================== |
// |
// ide.h |
// |
// IDE Interface Driver Tables for RedBoot |
// |
//========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//========================================================================== |
//#####DESCRIPTIONBEGIN#### |
// |
// Author(s): msalter |
// Contributors: msalter |
// Date: 2001-07-06 |
// Purpose: |
// Description: |
// |
// This code is part of RedBoot (tm). |
// |
//####DESCRIPTIONEND#### |
// |
//========================================================================== |
|
#ifndef CYGONCE_REDBOOT_IDE_H |
#define CYGONCE_REDBOOT_IDE_H |
|
// IDE Register Indices |
#define IDE_REG_DATA 0 |
#define IDE_REG_ERROR 1 |
#define IDE_REG_FEATURES 1 |
#define IDE_REG_COUNT 2 |
#define IDE_REG_REASON 2 // ATAPI |
#define IDE_REG_LBALOW 3 |
#define IDE_REG_LBAMID 4 |
#define IDE_REG_LBAHI 5 |
#define IDE_REG_DEVICE 6 |
#define IDE_REG_STATUS 7 |
#define IDE_REG_COMMAND 7 |
|
#define IDE_STAT_BSY 0x80 |
#define IDE_STAT_DRDY 0x40 |
#define IDE_STAT_SERVICE 0x10 |
#define IDE_STAT_DRQ 0x08 |
#define IDE_STAT_CORR 0x04 |
#define IDE_STAT_ERR 0x01 |
|
#define IDE_REASON_REL 0x04 |
#define IDE_REASON_IO 0x02 |
#define IDE_REASON_COD 0x01 |
|
// |
// Drive ID offsets of interest |
// |
#define IDE_DEVID_GENCONFIG 0 |
#define IDE_DEVID_SERNO 20 |
#define IDE_DEVID_MODEL 54 |
#define IDE_DEVID_LBA_CAPACITY 120 |
|
struct ide_priv { |
cyg_uint8 controller; |
cyg_uint8 drive; |
cyg_uint16 flags; |
}; |
|
/* flag values */ |
#define IDE_DEV_PRESENT 1 // Device is present |
#define IDE_DEV_PACKET 2 // Supports packet interface |
#define IDE_DEV_ADDR48 3 // Supports 48bit addressing |
|
#define CDROM_SECTOR_SIZE 2048 |
#define SECTORS_PER_CDROM_SECTOR (CDROM_SECTOR_SIZE/SECTOR_SIZE) |
|
#endif // CYGONCE_REDBOOT_IDE_H |