2 * ZFS filesystem port for Uboot by
3 * Jorgen Lundman <lundman at lundman.net>
6 * made from existing GRUB Sources by Sun, GNU and others.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #ifndef __ZFS_COMMON__
23 #define __ZFS_COMMON__
27 #define SECTOR_SIZE 0x200
30 typedef enum zfs_endian
{
37 #define zfs_to_cpu16(x, a) (((a) == BIG_ENDIAN) ? be16_to_cpu(x) \
39 #define cpu_to_zfs16(x, a) (((a) == BIG_ENDIAN) ? cpu_to_be16(x) \
42 #define zfs_to_cpu32(x, a) (((a) == BIG_ENDIAN) ? be32_to_cpu(x) \
44 #define cpu_to_zfs32(x, a) (((a) == BIG_ENDIAN) ? cpu_to_be32(x) \
47 #define zfs_to_cpu64(x, a) (((a) == BIG_ENDIAN) ? be64_to_cpu(x) \
49 #define cpu_to_zfs64(x, a) (((a) == BIG_ENDIAN) ? cpu_to_be64(x) \
54 ZFS_ERR_NOT_IMPLEMENTED_YET
= -1,
56 ZFS_ERR_OUT_OF_MEMORY
= -3,
57 ZFS_ERR_FILE_NOT_FOUND
= -4,
58 ZFS_ERR_BAD_FILE_TYPE
= -5,
59 ZFS_ERR_OUT_OF_RANGE
= -6,
62 struct zfs_filesystem
{
64 /* Block Device Descriptor */
65 struct blk_desc
*dev_desc
;
71 typedef struct device_s
*device_t
;
80 typedef struct zfs_file
*zfs_file_t
;
82 struct zfs_dirhook_info
{
89 struct zfs_filesystem
*zfsget_fs(void);
90 int zfs_open(zfs_file_t
, const char *filename
);
91 uint64_t zfs_read(zfs_file_t
, char *buf
, uint64_t len
);
92 struct zfs_data
*zfs_mount(device_t
);
93 int zfs_close(zfs_file_t
);
94 int zfs_ls(device_t dev
, const char *path
,
95 int (*hook
) (const char *, const struct zfs_dirhook_info
*));
96 int zfs_devread(int sector
, int byte_offset
, int byte_len
, char *buf
);
97 void zfs_set_blk_dev(struct blk_desc
*rbdd
, struct disk_partition
*info
);
98 void zfs_unmount(struct zfs_data
*data
);
99 int lzjb_decompress(void *, void *, uint32_t, uint32_t);