From ae51f41d14f548d494ac41e0d21137c5a4c3f59c Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Wed, 30 Oct 2019 14:21:52 +0800 Subject: import the U-Boot code and make it compile --- dev.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 dev.c (limited to 'dev.c') diff --git a/dev.c b/dev.c new file mode 100644 index 0000000..2907688 --- /dev/null +++ b/dev.c @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2011 - 2012 Samsung Electronics + * EXT4 filesystem implementation in Uboot by + * Uma Shankar + * Manjunatha C Achar + * + * made from existing ext2/dev.c file of Uboot + * (C) Copyright 2004 + * esd gmbh + * Reinhard Arlt + * + * based on code of fs/reiserfs/dev.c by + * + * (C) Copyright 2003 - 2004 + * Sysgo AG, , Pavel Bartusek + */ + +/* + * Changelog: + * 0.1 - Newly created file for ext4fs support. Taken from + * fs/ext2/dev.c file in uboot. + */ + +#include +#include +#include +#include +#include +#include +#include "ext4_common.h" + +lbaint_t part_offset; + +static struct blk_desc *ext4fs_blk_desc; +static disk_partition_t *part_info; + +void ext4fs_set_blk_dev(struct blk_desc *rbdd, disk_partition_t *info) +{ + assert(rbdd->blksz == (1 << rbdd->log2blksz)); + ext4fs_blk_desc = rbdd; + get_fs()->dev_desc = rbdd; + part_info = info; + part_offset = info->start; + get_fs()->total_sect = ((uint64_t)info->size * info->blksz) >> + get_fs()->dev_desc->log2blksz; +} + +int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, + char *buffer) +{ + return fs_devread(get_fs()->dev_desc, part_info, sector, byte_offset, + byte_len, buffer); +} + +int ext4_read_superblock(char *buffer) +{ + struct ext_filesystem *fs = get_fs(); + int sect = SUPERBLOCK_START >> fs->dev_desc->log2blksz; + int off = SUPERBLOCK_START % fs->dev_desc->blksz; + + return ext4fs_devread(sect, off, SUPERBLOCK_SIZE, + buffer); +} -- cgit v1.2.3