cmd_mgdisk.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * (C) Copyright 2009 mGine co.
  3. * unsik Kim <donari75@gmail.com>
  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. #include <common.h>
  24. #include <command.h>
  25. #if defined (CONFIG_CMD_MG_DISK)
  26. #include <mg_disk.h>
  27. int do_mg_disk_cmd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  28. {
  29. u32 from, to, size;
  30. switch (argc) {
  31. case 2:
  32. if (!strcmp(argv[1], "init"))
  33. mg_disk_init();
  34. else
  35. return 1;
  36. break;
  37. case 5:
  38. from = simple_strtoul(argv[2], NULL, 0);
  39. to = simple_strtoul(argv[3], NULL, 0);
  40. size = simple_strtoul(argv[4], NULL, 0);
  41. if (!strcmp(argv[1], "read"))
  42. mg_disk_read(from, (u8 *)to, size);
  43. else if (!strcmp(argv[1], "write"))
  44. mg_disk_write(to, (u8 *)from, size);
  45. else if (!strcmp(argv[1], "readsec"))
  46. mg_disk_read_sects((void *)to, from, size);
  47. else if (!strcmp(argv[1], "writesec"))
  48. mg_disk_write_sects((void *)from, to, size);
  49. else
  50. return 1;
  51. break;
  52. default:
  53. printf("Usage:\n%s\n", cmdtp->usage);
  54. return 1;
  55. }
  56. return 0;
  57. }
  58. U_BOOT_CMD(
  59. mgd, 5, 0, do_mg_disk_cmd,
  60. "mgd - mgine m[g]flash command\n",
  61. ": mgine mflash IO mode (disk) command\n"
  62. " - initialize : mgd init\n"
  63. " - random read : mgd read [from] [to] [size]\n"
  64. " - random write : mgd write [from] [to] [size]\n"
  65. " - sector read : mgd readsec [sector] [to] [counts]\n"
  66. " - sector write : mgd writesec [from] [sector] [counts]\n"
  67. );
  68. #endif