wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2001 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 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. |
| 12 | * |
| 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. |
| 17 | * |
| 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, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
| 25 | #include <command.h> |
| 26 | #include <ide.h> |
Grant Likely | 735dd97 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 27 | #include <part.h> |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 28 | |
| 29 | #undef PART_DEBUG |
| 30 | |
| 31 | #ifdef PART_DEBUG |
| 32 | #define PRINTF(fmt,args...) printf (fmt ,##args) |
| 33 | #else |
| 34 | #define PRINTF(fmt,args...) |
| 35 | #endif |
| 36 | |
Jon Loeliger | cde5c64 | 2007-07-09 17:22:37 -0500 | [diff] [blame] | 37 | #if (defined(CONFIG_CMD_IDE) || \ |
unsik Kim | 75eb82e | 2009-02-25 11:31:24 +0900 | [diff] [blame] | 38 | defined(CONFIG_CMD_MG_DISK) || \ |
Dave Liu | c7057b5 | 2008-03-26 22:49:44 +0800 | [diff] [blame] | 39 | defined(CONFIG_CMD_SATA) || \ |
Jon Loeliger | cde5c64 | 2007-07-09 17:22:37 -0500 | [diff] [blame] | 40 | defined(CONFIG_CMD_SCSI) || \ |
| 41 | defined(CONFIG_CMD_USB) || \ |
wdenk | 1968e61 | 2005-02-24 23:23:29 +0000 | [diff] [blame] | 42 | defined(CONFIG_MMC) || \ |
| 43 | defined(CONFIG_SYSTEMACE) ) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 44 | |
Grant Likely | 735dd97 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 45 | struct block_drvr { |
| 46 | char *name; |
| 47 | block_dev_desc_t* (*get_dev)(int dev); |
| 48 | }; |
| 49 | |
| 50 | static const struct block_drvr block_drvr[] = { |
Jon Loeliger | cde5c64 | 2007-07-09 17:22:37 -0500 | [diff] [blame] | 51 | #if defined(CONFIG_CMD_IDE) |
Grant Likely | 735dd97 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 52 | { .name = "ide", .get_dev = ide_get_dev, }, |
| 53 | #endif |
Dave Liu | c7057b5 | 2008-03-26 22:49:44 +0800 | [diff] [blame] | 54 | #if defined(CONFIG_CMD_SATA) |
| 55 | {.name = "sata", .get_dev = sata_get_dev, }, |
| 56 | #endif |
Jon Loeliger | cde5c64 | 2007-07-09 17:22:37 -0500 | [diff] [blame] | 57 | #if defined(CONFIG_CMD_SCSI) |
Grant Likely | 735dd97 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 58 | { .name = "scsi", .get_dev = scsi_get_dev, }, |
| 59 | #endif |
Jon Loeliger | cde5c64 | 2007-07-09 17:22:37 -0500 | [diff] [blame] | 60 | #if defined(CONFIG_CMD_USB) && defined(CONFIG_USB_STORAGE) |
Grant Likely | 735dd97 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 61 | { .name = "usb", .get_dev = usb_stor_get_dev, }, |
| 62 | #endif |
| 63 | #if defined(CONFIG_MMC) |
| 64 | { .name = "mmc", .get_dev = mmc_get_dev, }, |
| 65 | #endif |
| 66 | #if defined(CONFIG_SYSTEMACE) |
| 67 | { .name = "ace", .get_dev = systemace_get_dev, }, |
| 68 | #endif |
unsik Kim | 75eb82e | 2009-02-25 11:31:24 +0900 | [diff] [blame] | 69 | #if defined(CONFIG_CMD_MG_DISK) |
| 70 | { .name = "mgd", .get_dev = mg_disk_get_dev, }, |
| 71 | #endif |
Grant Likely | 735dd97 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 72 | { }, |
| 73 | }; |
| 74 | |
Stefan Roese | 751bb57 | 2007-02-20 13:21:57 +0100 | [diff] [blame] | 75 | DECLARE_GLOBAL_DATA_PTR; |
Stefan Roese | 751bb57 | 2007-02-20 13:21:57 +0100 | [diff] [blame] | 76 | |
Grant Likely | 735dd97 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 77 | block_dev_desc_t *get_dev(char* ifname, int dev) |
| 78 | { |
| 79 | const struct block_drvr *drvr = block_drvr; |
Stefan Roese | 6c7cac8 | 2007-02-22 07:43:34 +0100 | [diff] [blame] | 80 | block_dev_desc_t* (*reloc_get_dev)(int dev); |
Grant Likely | 735dd97 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 81 | |
| 82 | while (drvr->name) { |
Peter Tyser | 521af04 | 2009-09-21 11:20:36 -0500 | [diff] [blame] | 83 | reloc_get_dev = drvr->get_dev; |
| 84 | #ifndef CONFIG_RELOC_FIXUP_WORKS |
| 85 | reloc_get_dev += gd->reloc_off; |
| 86 | #endif |
Stefan Roese | 751bb57 | 2007-02-20 13:21:57 +0100 | [diff] [blame] | 87 | if (strncmp(ifname, drvr->name, strlen(drvr->name)) == 0) |
| 88 | return reloc_get_dev(dev); |
Grant Likely | 735dd97 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 89 | drvr++; |
| 90 | } |
| 91 | return NULL; |
| 92 | } |
| 93 | #else |
| 94 | block_dev_desc_t *get_dev(char* ifname, int dev) |
| 95 | { |
| 96 | return NULL; |
| 97 | } |
| 98 | #endif |
| 99 | |
Jon Loeliger | cde5c64 | 2007-07-09 17:22:37 -0500 | [diff] [blame] | 100 | #if (defined(CONFIG_CMD_IDE) || \ |
unsik Kim | 75eb82e | 2009-02-25 11:31:24 +0900 | [diff] [blame] | 101 | defined(CONFIG_CMD_MG_DISK) || \ |
Dave Liu | c7057b5 | 2008-03-26 22:49:44 +0800 | [diff] [blame] | 102 | defined(CONFIG_CMD_SATA) || \ |
Jon Loeliger | cde5c64 | 2007-07-09 17:22:37 -0500 | [diff] [blame] | 103 | defined(CONFIG_CMD_SCSI) || \ |
| 104 | defined(CONFIG_CMD_USB) || \ |
Grant Likely | 735dd97 | 2007-02-20 09:04:34 +0100 | [diff] [blame] | 105 | defined(CONFIG_MMC) || \ |
| 106 | defined(CONFIG_SYSTEMACE) ) |
| 107 | |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 108 | /* ------------------------------------------------------------------------- */ |
| 109 | /* |
| 110 | * reports device info to the user |
| 111 | */ |
Sergei Trofimovich | 69a2a4d | 2010-08-08 15:05:39 +0300 | [diff] [blame] | 112 | |
| 113 | #ifdef CONFIG_LBA48 |
| 114 | typedef uint64_t lba512_t; |
| 115 | #else |
| 116 | typedef lbaint_t lba512_t; |
| 117 | #endif |
| 118 | |
| 119 | /* |
| 120 | * Overflowless variant of (block_count * mul_by / div_by) |
| 121 | * when div_by > mul_by |
| 122 | */ |
| 123 | static lba512_t lba512_muldiv (lba512_t block_count, lba512_t mul_by, lba512_t div_by) |
| 124 | { |
| 125 | lba512_t bc_quot, bc_rem; |
| 126 | |
| 127 | /* x * m / d == x / d * m + (x % d) * m / d */ |
| 128 | bc_quot = block_count / div_by; |
| 129 | bc_rem = block_count - div_by * bc_quot; |
| 130 | return bc_quot * mul_by + (bc_rem * mul_by) / div_by; |
| 131 | } |
| 132 | |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 133 | void dev_print (block_dev_desc_t *dev_desc) |
| 134 | { |
Sergei Trofimovich | 69a2a4d | 2010-08-08 15:05:39 +0300 | [diff] [blame] | 135 | lba512_t lba512; /* number of blocks if 512bytes block size */ |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 136 | |
Wolfgang Denk | af75a45 | 2009-05-15 09:27:58 +0200 | [diff] [blame] | 137 | if (dev_desc->type == DEV_TYPE_UNKNOWN) { |
| 138 | puts ("not available\n"); |
| 139 | return; |
| 140 | } |
| 141 | |
Tor Krill | 8ec6e33 | 2008-05-29 11:10:30 +0200 | [diff] [blame] | 142 | switch (dev_desc->if_type) { |
Detlev Zundel | 574b319 | 2008-05-05 16:11:21 +0200 | [diff] [blame] | 143 | case IF_TYPE_SCSI: |
| 144 | printf ("(%d:%d) Vendor: %s Prod.: %s Rev: %s\n", |
| 145 | dev_desc->target,dev_desc->lun, |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 146 | dev_desc->vendor, |
| 147 | dev_desc->product, |
| 148 | dev_desc->revision); |
Detlev Zundel | 574b319 | 2008-05-05 16:11:21 +0200 | [diff] [blame] | 149 | break; |
Remy Bohmer | 6e24a1e | 2008-09-19 13:30:06 +0200 | [diff] [blame] | 150 | case IF_TYPE_ATAPI: |
Detlev Zundel | 574b319 | 2008-05-05 16:11:21 +0200 | [diff] [blame] | 151 | case IF_TYPE_IDE: |
| 152 | case IF_TYPE_SATA: |
| 153 | printf ("Model: %s Firm: %s Ser#: %s\n", |
| 154 | dev_desc->vendor, |
| 155 | dev_desc->revision, |
| 156 | dev_desc->product); |
| 157 | break; |
Remy Bohmer | 6e24a1e | 2008-09-19 13:30:06 +0200 | [diff] [blame] | 158 | case IF_TYPE_SD: |
| 159 | case IF_TYPE_MMC: |
NÃcolas Carneiro Lebedenco | 47bebe3 | 2008-09-04 15:35:46 -0300 | [diff] [blame] | 160 | case IF_TYPE_USB: |
| 161 | printf ("Vendor: %s Rev: %s Prod: %s\n", |
| 162 | dev_desc->vendor, |
| 163 | dev_desc->revision, |
| 164 | dev_desc->product); |
| 165 | break; |
Remy Bohmer | 6e24a1e | 2008-09-19 13:30:06 +0200 | [diff] [blame] | 166 | case IF_TYPE_DOC: |
| 167 | puts("device type DOC\n"); |
| 168 | return; |
Tor Krill | 8ec6e33 | 2008-05-29 11:10:30 +0200 | [diff] [blame] | 169 | case IF_TYPE_UNKNOWN: |
Remy Bohmer | 6e24a1e | 2008-09-19 13:30:06 +0200 | [diff] [blame] | 170 | puts("device type unknown\n"); |
| 171 | return; |
Detlev Zundel | 574b319 | 2008-05-05 16:11:21 +0200 | [diff] [blame] | 172 | default: |
Remy Bohmer | 6e24a1e | 2008-09-19 13:30:06 +0200 | [diff] [blame] | 173 | printf("Unhandled device type: %i\n", dev_desc->if_type); |
Detlev Zundel | 574b319 | 2008-05-05 16:11:21 +0200 | [diff] [blame] | 174 | return; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 175 | } |
| 176 | puts (" Type: "); |
| 177 | if (dev_desc->removable) |
| 178 | puts ("Removable "); |
| 179 | switch (dev_desc->type & 0x1F) { |
Detlev Zundel | 726c0f1 | 2008-05-05 16:11:22 +0200 | [diff] [blame] | 180 | case DEV_TYPE_HARDDISK: |
| 181 | puts ("Hard Disk"); |
| 182 | break; |
| 183 | case DEV_TYPE_CDROM: |
| 184 | puts ("CD ROM"); |
| 185 | break; |
| 186 | case DEV_TYPE_OPDISK: |
| 187 | puts ("Optical Device"); |
| 188 | break; |
| 189 | case DEV_TYPE_TAPE: |
| 190 | puts ("Tape"); |
| 191 | break; |
| 192 | default: |
| 193 | printf ("# %02X #", dev_desc->type & 0x1F); |
| 194 | break; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 195 | } |
| 196 | puts ("\n"); |
| 197 | if ((dev_desc->lba * dev_desc->blksz)>0L) { |
| 198 | ulong mb, mb_quot, mb_rem, gb, gb_quot, gb_rem; |
wdenk | c40b295 | 2004-03-13 23:29:43 +0000 | [diff] [blame] | 199 | lbaint_t lba; |
wdenk | 6e59238 | 2004-04-18 17:39:38 +0000 | [diff] [blame] | 200 | |
| 201 | lba = dev_desc->lba; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 202 | |
wdenk | c40b295 | 2004-03-13 23:29:43 +0000 | [diff] [blame] | 203 | lba512 = (lba * (dev_desc->blksz/512)); |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 204 | /* round to 1 digit */ |
Sergei Trofimovich | 69a2a4d | 2010-08-08 15:05:39 +0300 | [diff] [blame] | 205 | mb = lba512_muldiv(lba512, 10, 2048); /* 2048 = (1024 * 1024) / 512 MB */ |
| 206 | |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 207 | mb_quot = mb / 10; |
| 208 | mb_rem = mb - (10 * mb_quot); |
| 209 | |
| 210 | gb = mb / 1024; |
| 211 | gb_quot = gb / 10; |
| 212 | gb_rem = gb - (10 * gb_quot); |
wdenk | 42dfe7a | 2004-03-14 22:25:36 +0000 | [diff] [blame] | 213 | #ifdef CONFIG_LBA48 |
wdenk | 6e59238 | 2004-04-18 17:39:38 +0000 | [diff] [blame] | 214 | if (dev_desc->lba48) |
wdenk | c40b295 | 2004-03-13 23:29:43 +0000 | [diff] [blame] | 215 | printf (" Supports 48-bit addressing\n"); |
| 216 | #endif |
Heiko Schocher | 4b142fe | 2009-12-03 11:21:21 +0100 | [diff] [blame] | 217 | #if defined(CONFIG_SYS_64BIT_LBA) |
Mike Frysinger | 6c6166f | 2009-02-16 23:21:36 -0500 | [diff] [blame] | 218 | printf (" Capacity: %ld.%ld MB = %ld.%ld GB (%Ld x %ld)\n", |
wdenk | c40b295 | 2004-03-13 23:29:43 +0000 | [diff] [blame] | 219 | mb_quot, mb_rem, |
| 220 | gb_quot, gb_rem, |
| 221 | lba, |
| 222 | dev_desc->blksz); |
| 223 | #else |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 224 | printf (" Capacity: %ld.%ld MB = %ld.%ld GB (%ld x %ld)\n", |
| 225 | mb_quot, mb_rem, |
| 226 | gb_quot, gb_rem, |
wdenk | c40b295 | 2004-03-13 23:29:43 +0000 | [diff] [blame] | 227 | (ulong)lba, |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 228 | dev_desc->blksz); |
wdenk | c40b295 | 2004-03-13 23:29:43 +0000 | [diff] [blame] | 229 | #endif |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 230 | } else { |
| 231 | puts (" Capacity: not available\n"); |
| 232 | } |
| 233 | } |
Jon Loeliger | b3aff0c | 2007-07-10 11:19:50 -0500 | [diff] [blame] | 234 | #endif |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 235 | |
Jon Loeliger | cde5c64 | 2007-07-09 17:22:37 -0500 | [diff] [blame] | 236 | #if (defined(CONFIG_CMD_IDE) || \ |
unsik Kim | 75eb82e | 2009-02-25 11:31:24 +0900 | [diff] [blame] | 237 | defined(CONFIG_CMD_MG_DISK) || \ |
Dave Liu | c7057b5 | 2008-03-26 22:49:44 +0800 | [diff] [blame] | 238 | defined(CONFIG_CMD_SATA) || \ |
Jon Loeliger | cde5c64 | 2007-07-09 17:22:37 -0500 | [diff] [blame] | 239 | defined(CONFIG_CMD_SCSI) || \ |
| 240 | defined(CONFIG_CMD_USB) || \ |
Haavard Skinnemoen | 7fac3f6 | 2006-12-17 18:53:56 +0100 | [diff] [blame] | 241 | defined(CONFIG_MMC) || \ |
unsik Kim | 75eb82e | 2009-02-25 11:31:24 +0900 | [diff] [blame] | 242 | defined(CONFIG_SYSTEMACE) ) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 243 | |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 244 | #if defined(CONFIG_MAC_PARTITION) || \ |
| 245 | defined(CONFIG_DOS_PARTITION) || \ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 246 | defined(CONFIG_ISO_PARTITION) || \ |
richardretanubun | 07f3d78 | 2008-09-26 11:13:22 -0400 | [diff] [blame] | 247 | defined(CONFIG_AMIGA_PARTITION) || \ |
| 248 | defined(CONFIG_EFI_PARTITION) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 249 | |
| 250 | void init_part (block_dev_desc_t * dev_desc) |
| 251 | { |
| 252 | #ifdef CONFIG_ISO_PARTITION |
| 253 | if (test_part_iso(dev_desc) == 0) { |
| 254 | dev_desc->part_type = PART_TYPE_ISO; |
| 255 | return; |
| 256 | } |
| 257 | #endif |
| 258 | |
| 259 | #ifdef CONFIG_MAC_PARTITION |
| 260 | if (test_part_mac(dev_desc) == 0) { |
| 261 | dev_desc->part_type = PART_TYPE_MAC; |
| 262 | return; |
| 263 | } |
| 264 | #endif |
| 265 | |
richardretanubun | 07f3d78 | 2008-09-26 11:13:22 -0400 | [diff] [blame] | 266 | /* must be placed before DOS partition detection */ |
| 267 | #ifdef CONFIG_EFI_PARTITION |
| 268 | if (test_part_efi(dev_desc) == 0) { |
| 269 | dev_desc->part_type = PART_TYPE_EFI; |
| 270 | return; |
| 271 | } |
| 272 | #endif |
| 273 | |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 274 | #ifdef CONFIG_DOS_PARTITION |
| 275 | if (test_part_dos(dev_desc) == 0) { |
| 276 | dev_desc->part_type = PART_TYPE_DOS; |
| 277 | return; |
| 278 | } |
| 279 | #endif |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 280 | |
| 281 | #ifdef CONFIG_AMIGA_PARTITION |
| 282 | if (test_part_amiga(dev_desc) == 0) { |
| 283 | dev_desc->part_type = PART_TYPE_AMIGA; |
| 284 | return; |
| 285 | } |
| 286 | #endif |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | |
Peter Pearse | 3e3b956 | 2007-05-18 16:47:03 +0100 | [diff] [blame] | 290 | int get_partition_info (block_dev_desc_t *dev_desc, int part |
| 291 | , disk_partition_t *info) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 292 | { |
Heiko Schocher | 566a494 | 2007-06-22 19:11:54 +0200 | [diff] [blame] | 293 | switch (dev_desc->part_type) { |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 294 | #ifdef CONFIG_MAC_PARTITION |
| 295 | case PART_TYPE_MAC: |
| 296 | if (get_partition_info_mac(dev_desc,part,info) == 0) { |
| 297 | PRINTF ("## Valid MAC partition found ##\n"); |
| 298 | return (0); |
| 299 | } |
| 300 | break; |
| 301 | #endif |
| 302 | |
| 303 | #ifdef CONFIG_DOS_PARTITION |
| 304 | case PART_TYPE_DOS: |
| 305 | if (get_partition_info_dos(dev_desc,part,info) == 0) { |
| 306 | PRINTF ("## Valid DOS partition found ##\n"); |
| 307 | return (0); |
| 308 | } |
| 309 | break; |
| 310 | #endif |
| 311 | |
| 312 | #ifdef CONFIG_ISO_PARTITION |
| 313 | case PART_TYPE_ISO: |
| 314 | if (get_partition_info_iso(dev_desc,part,info) == 0) { |
| 315 | PRINTF ("## Valid ISO boot partition found ##\n"); |
| 316 | return (0); |
| 317 | } |
| 318 | break; |
| 319 | #endif |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 320 | |
| 321 | #ifdef CONFIG_AMIGA_PARTITION |
| 322 | case PART_TYPE_AMIGA: |
| 323 | if (get_partition_info_amiga(dev_desc, part, info) == 0) |
| 324 | { |
| 325 | PRINTF ("## Valid Amiga partition found ##\n"); |
| 326 | return (0); |
| 327 | } |
| 328 | break; |
| 329 | #endif |
richardretanubun | 07f3d78 | 2008-09-26 11:13:22 -0400 | [diff] [blame] | 330 | |
| 331 | #ifdef CONFIG_EFI_PARTITION |
| 332 | case PART_TYPE_EFI: |
| 333 | if (get_partition_info_efi(dev_desc,part,info) == 0) { |
| 334 | PRINTF ("## Valid EFI partition found ##\n"); |
| 335 | return (0); |
| 336 | } |
| 337 | break; |
| 338 | #endif |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 339 | default: |
| 340 | break; |
| 341 | } |
| 342 | return (-1); |
| 343 | } |
| 344 | |
| 345 | static void print_part_header (const char *type, block_dev_desc_t * dev_desc) |
| 346 | { |
| 347 | puts ("\nPartition Map for "); |
| 348 | switch (dev_desc->if_type) { |
Detlev Zundel | 726c0f1 | 2008-05-05 16:11:22 +0200 | [diff] [blame] | 349 | case IF_TYPE_IDE: |
| 350 | puts ("IDE"); |
| 351 | break; |
| 352 | case IF_TYPE_SATA: |
| 353 | puts ("SATA"); |
| 354 | break; |
| 355 | case IF_TYPE_SCSI: |
| 356 | puts ("SCSI"); |
| 357 | break; |
| 358 | case IF_TYPE_ATAPI: |
| 359 | puts ("ATAPI"); |
| 360 | break; |
| 361 | case IF_TYPE_USB: |
| 362 | puts ("USB"); |
| 363 | break; |
| 364 | case IF_TYPE_DOC: |
| 365 | puts ("DOC"); |
| 366 | break; |
| 367 | default: |
| 368 | puts ("UNKNOWN"); |
| 369 | break; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 370 | } |
| 371 | printf (" device %d -- Partition Type: %s\n\n", |
| 372 | dev_desc->dev, type); |
| 373 | } |
| 374 | |
| 375 | void print_part (block_dev_desc_t * dev_desc) |
| 376 | { |
| 377 | |
| 378 | switch (dev_desc->part_type) { |
| 379 | #ifdef CONFIG_MAC_PARTITION |
| 380 | case PART_TYPE_MAC: |
| 381 | PRINTF ("## Testing for valid MAC partition ##\n"); |
| 382 | print_part_header ("MAC", dev_desc); |
| 383 | print_part_mac (dev_desc); |
| 384 | return; |
| 385 | #endif |
| 386 | #ifdef CONFIG_DOS_PARTITION |
| 387 | case PART_TYPE_DOS: |
| 388 | PRINTF ("## Testing for valid DOS partition ##\n"); |
| 389 | print_part_header ("DOS", dev_desc); |
| 390 | print_part_dos (dev_desc); |
| 391 | return; |
| 392 | #endif |
| 393 | |
| 394 | #ifdef CONFIG_ISO_PARTITION |
| 395 | case PART_TYPE_ISO: |
| 396 | PRINTF ("## Testing for valid ISO Boot partition ##\n"); |
| 397 | print_part_header ("ISO", dev_desc); |
| 398 | print_part_iso (dev_desc); |
| 399 | return; |
| 400 | #endif |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 401 | |
| 402 | #ifdef CONFIG_AMIGA_PARTITION |
| 403 | case PART_TYPE_AMIGA: |
| 404 | PRINTF ("## Testing for a valid Amiga partition ##\n"); |
| 405 | print_part_header ("AMIGA", dev_desc); |
| 406 | print_part_amiga (dev_desc); |
| 407 | return; |
| 408 | #endif |
richardretanubun | 07f3d78 | 2008-09-26 11:13:22 -0400 | [diff] [blame] | 409 | |
| 410 | #ifdef CONFIG_EFI_PARTITION |
| 411 | case PART_TYPE_EFI: |
| 412 | PRINTF ("## Testing for valid EFI partition ##\n"); |
| 413 | print_part_header ("EFI", dev_desc); |
| 414 | print_part_efi (dev_desc); |
| 415 | return; |
| 416 | #endif |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 417 | } |
| 418 | puts ("## Unknown partition table\n"); |
| 419 | } |
| 420 | |
| 421 | |
richardretanubun | 07f3d78 | 2008-09-26 11:13:22 -0400 | [diff] [blame] | 422 | #else /* neither MAC nor DOS nor ISO nor AMIGA nor EFI partition configured */ |
Wolfgang Denk | 725671c | 2007-06-06 16:26:56 +0200 | [diff] [blame] | 423 | # error neither CONFIG_MAC_PARTITION nor CONFIG_DOS_PARTITION |
richardretanubun | 07f3d78 | 2008-09-26 11:13:22 -0400 | [diff] [blame] | 424 | # error nor CONFIG_ISO_PARTITION nor CONFIG_AMIGA_PARTITION |
| 425 | # error nor CONFIG_EFI_PARTITION configured! |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 426 | #endif |
| 427 | |
Jon Loeliger | cde5c64 | 2007-07-09 17:22:37 -0500 | [diff] [blame] | 428 | #endif |