]> git.ipfire.org Git - thirdparty/u-boot.git/blame - cmd/reiser.c
efi: Create a function to set up for running EFI code
[thirdparty/u-boot.git] / cmd / reiser.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
518e2e1a
WD
2/*
3 * (C) Copyright 2003 - 2004
4 * Sysgo Real-Time Solutions, AG <www.elinos.com>
5 * Pavel Bartusek <pba@sysgo.com>
518e2e1a
WD
6 */
7
8/*
9 * Reiserfs support
10 */
11#include <common.h>
518e2e1a
WD
12#include <config.h>
13#include <command.h>
14#include <image.h>
15#include <linux/ctype.h>
16#include <asm/byteorder.h>
17#include <reiserfs.h>
735dd97b 18#include <part.h>
518e2e1a 19
b0cf7339 20#if !CONFIG_IS_ENABLED(DOS_PARTITION)
518e2e1a
WD
21#error DOS partition support must be selected
22#endif
23
24/* #define REISER_DEBUG */
25
26#ifdef REISER_DEBUG
27#define PRINTF(fmt,args...) printf (fmt ,##args)
28#else
29#define PRINTF(fmt,args...)
30#endif
31
54841ab5 32int do_reiserls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
518e2e1a
WD
33{
34 char *filename = "/";
650f3664 35 int dev, part;
4101f687 36 struct blk_desc *dev_desc = NULL;
650f3664 37 disk_partition_t info;
518e2e1a 38
47e26b1b 39 if (argc < 3)
4c12eeb8 40 return CMD_RET_USAGE;
47e26b1b 41
e35929e4 42 part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
650f3664 43 if (part < 0)
518e2e1a 44 return 1;
518e2e1a
WD
45
46 if (argc == 4) {
47 filename = argv[3];
48 }
49
bcce53d0 50 dev = dev_desc->devnum;
518e2e1a
WD
51 PRINTF("Using device %s %d:%d, directory: %s\n", argv[1], dev, part, filename);
52
650f3664 53 reiserfs_set_blk_dev(dev_desc, &info);
518e2e1a 54
650f3664 55 if (!reiserfs_mount(info.size)) {
566a494f 56 printf ("** Bad Reiserfs partition or disk - %s %d:%d **\n", argv[1], dev, part);
518e2e1a
WD
57 return 1;
58 }
59
60 if (reiserfs_ls (filename)) {
61 printf ("** Error reiserfs_ls() **\n");
62 return 1;
63 };
64
65 return 0;
66}
67
68U_BOOT_CMD(
69 reiserls, 4, 1, do_reiserls,
2fb2604d 70 "list files in a directory (default /)",
518e2e1a 71 "<interface> <dev[:part]> [directory]\n"
a89c33db 72 " - list files from 'dev' on 'interface' in a 'directory'"
518e2e1a
WD
73);
74
75/******************************************************************************
76 * Reiserfs boot command intepreter. Derived from diskboot
77 */
54841ab5 78int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
518e2e1a
WD
79{
80 char *filename = NULL;
650f3664
RH
81 int dev, part;
82 ulong addr = 0, filelen;
518e2e1a 83 disk_partition_t info;
4101f687 84 struct blk_desc *dev_desc = NULL;
518e2e1a
WD
85 unsigned long count;
86 char *addr_str;
87
88 switch (argc) {
89 case 3:
00caae6d 90 addr_str = env_get("loadaddr");
518e2e1a
WD
91 if (addr_str != NULL) {
92 addr = simple_strtoul (addr_str, NULL, 16);
93 } else {
6d0f6bcf 94 addr = CONFIG_SYS_LOAD_ADDR;
518e2e1a 95 }
00caae6d 96 filename = env_get("bootfile");
518e2e1a
WD
97 count = 0;
98 break;
99 case 4:
100 addr = simple_strtoul (argv[3], NULL, 16);
00caae6d 101 filename = env_get("bootfile");
518e2e1a
WD
102 count = 0;
103 break;
104 case 5:
105 addr = simple_strtoul (argv[3], NULL, 16);
106 filename = argv[4];
107 count = 0;
108 break;
109 case 6:
110 addr = simple_strtoul (argv[3], NULL, 16);
111 filename = argv[4];
112 count = simple_strtoul (argv[5], NULL, 16);
113 break;
114
115 default:
4c12eeb8 116 return CMD_RET_USAGE;
518e2e1a
WD
117 }
118
119 if (!filename) {
120 puts ("\n** No boot file defined **\n");
121 return 1;
122 }
123
e35929e4 124 part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
650f3664 125 if (part < 0)
518e2e1a 126 return 1;
518e2e1a 127
bcce53d0 128 dev = dev_desc->devnum;
518e2e1a 129
650f3664
RH
130 printf("Loading file \"%s\" from %s device %d%c%c\n",
131 filename, argv[1], dev,
132 part ? ':' : ' ', part ? part + '0' : ' ');
518e2e1a 133
650f3664 134 reiserfs_set_blk_dev(dev_desc, &info);
518e2e1a 135
650f3664 136 if (!reiserfs_mount(info.size)) {
566a494f 137 printf ("** Bad Reiserfs partition or disk - %s %d:%d **\n", argv[1], dev, part);
518e2e1a
WD
138 return 1;
139 }
140
141 filelen = reiserfs_open(filename);
142 if (filelen < 0) {
2e18cb26 143 printf("** File not found %s **\n", filename);
518e2e1a
WD
144 return 1;
145 }
146 if ((count < filelen) && (count != 0)) {
147 filelen = count;
148 }
149
150 if (reiserfs_read((char *)addr, filelen) != filelen) {
151 printf("\n** Unable to read \"%s\" from %s %d:%d **\n", filename, argv[1], dev, part);
152 return 1;
153 }
154
155 /* Loading ok, update default load address */
156 load_addr = addr;
157
158 printf ("\n%ld bytes read\n", filelen);
018f5303 159 env_set_hex("filesize", filelen);
518e2e1a
WD
160
161 return filelen;
162}
163
164U_BOOT_CMD(
165 reiserload, 6, 0, do_reiserload,
2fb2604d 166 "load binary file from a Reiser filesystem",
518e2e1a
WD
167 "<interface> <dev[:part]> [addr] [filename] [bytes]\n"
168 " - load binary file 'filename' from 'dev' on 'interface'\n"
a89c33db 169 " to address 'addr' from dos filesystem"
518e2e1a 170);