/* * ar3c-kernel - lsbd.h * Copyright (C) 2010 Krzysztof Mazur * * This program 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 of the License, or * (at your option) any later version. * * This program 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 this program; if not, write to the Free Software Fundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __LINUX_LSBD_H #define __LINUX_LSBD_H #include // #include #include typedef uint8_t __u8; typedef uint32_t __u32; typedef uint64_t __u64; typedef uint8_t u8; typedef uint32_t u32; typedef uint64_t u64; #define LSBD_SET_DEV _IO('l', 0x0) #define LSBD_PART _IO('l', 0x1) #define LSBD_PART_MIRRORED 1 struct lsbd_part_info { __u32 num; __u32 start; __u32 size; __u32 flags; } __attribute__((packed)); #if __KERNEL__ || __LSBD_FORMAT__ #define LSBD_PART_MASK 0xffffff00 #define LSBD_PART_FLAGS_MASK 0xff #define LSBD_PART_MIRRORED 1 struct lsbd_part { u32 start_flags; u32 size_res; } __attribute__((packed)); #define LSBD_BLOCK_MAGIC 0x4c534244AA1122FFULL struct lsbd_block { u64 magic; /* 0x00 block magic */ u32 version; /* 0x08 block version */ u32 revision; /* 0x0c block revision */ u64 ctime; /* 0x10 lsbd device creation time */ u64 mtime; /* 0x18 last modify time */ u64 epoch; /* 0x20 unique block sequence number */ u64 age; /* 0x28 number of writes of this block */ u32 sector_size; /* 0x30 sector size in bytes */ u32 sectors_per_block; /* 0x34 in sectors */ u32 blocks; /* 0x38 number of blocks */ u32 lsectors; /* 0x3c number of logical sectors */ /* * lcache access needs to read previously written logical blocks, * not physical. This is for fast access of those blocks. * The i-th pointer specifies (1 << i) previous block. */ u32 prev_block[16]; /* 0x40 previous block table */ u32 ptab_offset; /* 0x80 */ u32 flags; /* 0x84 LSBD_* flags */ u32 pad1; /* 0x88 0 */ u32 ptab_checksum; /* 0x8c */ /* lcache - logical -> physical mapping cache */ u32 lcache_offset; /* 0x90 lcache location in block */ u32 lcache_base; /* 0x94 first logical sector in this cache */ u32 lcache_chunk; /* 0x98 number of entries per lcache */ u32 lcache_checksum; /* 0x9c lcache content checksum */ u32 pad2[(0x100 - 0xa0) / 4]; /* 0xc0 - reserved */ struct lsbd_part part[16]; /* 0x100-0x17f partition table */ u32 pad3[256 - 0x180/4 - 1]; /* 0xc0 */ u32 checksum; } __attribute__((packed)); /* LSBD flags */ #define LSBD_MIRRORED 1 /* block device uses mirroring */ struct lsbd_sect { u64 epoch; /* version of this sector */ u64 mtime; /* last modify time */ u32 id; /* sector id */ u32 age; /* weighted update frequency */ u32 flags; u32 data_checksum; /* data checksum */ } __attribute__((packed)); #define LSBD_SECT_INVALID 0xffffffffUL #define LSBD_SECT_ZERO 0xfffffffeUL /* * lcache is a table of physical mappings of logical sectors [lcache_base; * lcache_base + lcache_chunk) to physical sectors. */ typedef u32 lsbd_lcache_t; #endif #endif