3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 #define PRINTF(fmt,args...) printf (fmt ,##args)
34 #define PRINTF(fmt,args...)
37 #if ((CONFIG_COMMANDS & CFG_CMD_IDE) || \
38 (CONFIG_COMMANDS & CFG_CMD_SCSI) || \
39 (CONFIG_COMMANDS & CFG_CMD_USB) || \
40 defined(CONFIG_MMC) || \
41 defined(CONFIG_SYSTEMACE) )
43 /* ------------------------------------------------------------------------- */
45 * reports device info to the user
47 void dev_print (block_dev_desc_t
*dev_desc
)
50 uint64_t lba512
; /* number of blocks if 512bytes block size */
55 if (dev_desc
->type
==DEV_TYPE_UNKNOWN
) {
58 if (dev_desc
->if_type
==IF_TYPE_SCSI
) {
59 printf ("(%d:%d) ", dev_desc
->target
,dev_desc
->lun
);
61 if (dev_desc
->if_type
==IF_TYPE_IDE
) {
62 printf ("Model: %s Firm: %s Ser#: %s\n",
67 printf ("Vendor: %s Prod.: %s Rev: %s\n",
73 switch (dev_desc
->type
& 0x1F) {
74 case DEV_TYPE_HARDDISK
: printf ("Hard Disk");
76 case DEV_TYPE_CDROM
: printf ("CD ROM");
78 case DEV_TYPE_OPDISK
: printf ("Optical Device");
80 case DEV_TYPE_TAPE
: printf ("Tape");
82 default: printf ("# %02X #", dev_desc
->type
& 0x1F);
85 if ((dev_desc
->lba
* dev_desc
->blksz
)>0L) {
86 ulong mb
, mb_quot
, mb_rem
, gb
, gb_quot
, gb_rem
;
91 lba512
= (lba
* (dev_desc
->blksz
/512));
92 mb
= (10 * lba512
) / 2048; /* 2048 = (1024 * 1024) / 512 MB */
93 /* round to 1 digit */
95 mb_rem
= mb
- (10 * mb_quot
);
99 gb_rem
= gb
- (10 * gb_quot
);
102 printf (" Supports 48-bit addressing\n");
104 #if defined(CFG_64BIT_LBA) && defined(CFG_64BIT_VSPRINTF)
105 printf (" Capacity: %ld.%ld MB = %ld.%ld GB (%qd x %ld)\n",
111 printf (" Capacity: %ld.%ld MB = %ld.%ld GB (%ld x %ld)\n",
118 printf (" Capacity: not available\n");
121 #endif /* CFG_CMD_IDE || CFG_CMD_SCSI || CFG_CMD_USB || CONFIG_MMC */
123 #if ((CONFIG_COMMANDS & CFG_CMD_IDE) || \
124 (CONFIG_COMMANDS & CFG_CMD_SCSI) || \
125 (CONFIG_COMMANDS & CFG_CMD_USB) || \
126 (CONFIG_COMMANDS & CFG_CMD_MMC) || \
127 defined(CONFIG_SYSTEMACE) )
129 #if defined(CONFIG_MAC_PARTITION) || \
130 defined(CONFIG_DOS_PARTITION) || \
131 defined(CONFIG_ISO_PARTITION) || \
132 defined(CONFIG_AMIGA_PARTITION)
134 void init_part (block_dev_desc_t
* dev_desc
)
136 #ifdef CONFIG_ISO_PARTITION
137 if (test_part_iso(dev_desc
) == 0) {
138 dev_desc
->part_type
= PART_TYPE_ISO
;
143 #ifdef CONFIG_MAC_PARTITION
144 if (test_part_mac(dev_desc
) == 0) {
145 dev_desc
->part_type
= PART_TYPE_MAC
;
150 #ifdef CONFIG_DOS_PARTITION
151 if (test_part_dos(dev_desc
) == 0) {
152 dev_desc
->part_type
= PART_TYPE_DOS
;
157 #ifdef CONFIG_AMIGA_PARTITION
158 if (test_part_amiga(dev_desc
) == 0) {
159 dev_desc
->part_type
= PART_TYPE_AMIGA
;
166 int get_partition_info (block_dev_desc_t
*dev_desc
, int part
, disk_partition_t
*info
)
168 switch (dev_desc
->part_type
) {
169 #ifdef CONFIG_MAC_PARTITION
171 if (get_partition_info_mac(dev_desc
,part
,info
) == 0) {
172 PRINTF ("## Valid MAC partition found ##\n");
178 #ifdef CONFIG_DOS_PARTITION
180 if (get_partition_info_dos(dev_desc
,part
,info
) == 0) {
181 PRINTF ("## Valid DOS partition found ##\n");
187 #ifdef CONFIG_ISO_PARTITION
189 if (get_partition_info_iso(dev_desc
,part
,info
) == 0) {
190 PRINTF ("## Valid ISO boot partition found ##\n");
196 #ifdef CONFIG_AMIGA_PARTITION
197 case PART_TYPE_AMIGA
:
198 if (get_partition_info_amiga(dev_desc
, part
, info
) == 0)
200 PRINTF ("## Valid Amiga partition found ##\n");
211 static void print_part_header (const char *type
, block_dev_desc_t
* dev_desc
)
213 switch (dev_desc
->if_type
) {
214 case IF_TYPE_IDE
: printf ("IDE");
216 case IF_TYPE_SCSI
: printf ("SCSI");
218 case IF_TYPE_ATAPI
: printf ("ATAPI");
220 case IF_TYPE_USB
: printf ("USB");
222 case IF_TYPE_DOC
: printf ("DOC");
224 default: printf ("UNKNOWN");
227 printf (" device %d -- Partition Type: %s\n\n",
228 dev_desc
->dev
, type
);
231 void print_part (block_dev_desc_t
* dev_desc
)
234 switch (dev_desc
->part_type
) {
235 #ifdef CONFIG_MAC_PARTITION
237 PRINTF ("## Testing for valid MAC partition ##\n");
238 print_part_header ("MAC", dev_desc
);
239 print_part_mac (dev_desc
);
242 #ifdef CONFIG_DOS_PARTITION
244 PRINTF ("## Testing for valid DOS partition ##\n");
245 print_part_header ("DOS", dev_desc
);
246 print_part_dos (dev_desc
);
250 #ifdef CONFIG_ISO_PARTITION
252 PRINTF ("## Testing for valid ISO Boot partition ##\n");
253 print_part_header ("ISO", dev_desc
);
254 print_part_iso (dev_desc
);
258 #ifdef CONFIG_AMIGA_PARTITION
259 case PART_TYPE_AMIGA
:
260 PRINTF ("## Testing for a valid Amiga partition ##\n");
261 print_part_header ("AMIGA", dev_desc
);
262 print_part_amiga (dev_desc
);
269 #else /* neither MAC nor DOS nor ISO partition configured */
270 # error neither CONFIG_MAC_PARTITION nor CONFIG_DOS_PARTITION nor CONFIG_ISO_PARTITION configured!
273 #endif /* (CONFIG_COMMANDS & CFG_CMD_IDE) || CONFIG_COMMANDS & CFG_CMD_SCSI) */