RE: [PATCH] Add functionality to read the bootpart register

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 
> Currently the only way to read the bootpart register is to dump the whole extcsd
> register. This patch adds the possibility to read the bootpart register directly for
> situations where the whole extcsd is too verbose.
> 
> Signed-off-by: João Loureiro <joao.loureiro@xxxxxxxxxxx>
Please update mmc.1 as well.

Other than that - looks good to me.

Thanks,
Avri

> ---
>  mmc.c      |  5 +++++
>  mmc_cmds.c | 54
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  mmc_cmds.h |  1 +
>  3 files changed, 60 insertions(+)
> 
> diff --git a/mmc.c b/mmc.c
> index bc8f74e..26c4f13 100644
> --- a/mmc.c
> +++ b/mmc.c
> @@ -126,6 +126,11 @@ static struct Command commands[] = {
>                 "Enable the boot partition for the <device>.\nDisable the boot partition
> for the <device> if <boot_partition> is set to 0.\nTo receive acknowledgment of
> boot from the card set <send_ack>\nto 1, else set it to 0.",
>           NULL
>         },
> +       { do_read_boot_en, -1,
> +         "bootpart read", "<device>\n"
> +               "Read the boot partition information for the <device>.",
> +         NULL
> +       },
>         { do_boot_bus_conditions_set, -4,
>           "bootbus set", "<boot_mode> " "<reset_boot_bus_conditions> "
> "<boot_bus_width> " "<device>\n"
>           "Set Boot Bus Conditions.\n"
> diff --git a/mmc_cmds.c b/mmc_cmds.c
> index 936e0c5..add9e56 100644
> --- a/mmc_cmds.c
> +++ b/mmc_cmds.c
> @@ -233,6 +233,29 @@ static void print_writeprotect_boot_status(__u8
> *ext_csd)
>         }
>  }
> 
> +static void print_boot_en_status(__u8 *ext_csd) {
> +       __u8 reg;
> +
> +       reg = ext_csd[EXT_CSD_BOOT_CFG];
> +       printf("Configuration bytes [PARTITION_CONFIG: 0x%02x]\n " \
> +                  "Boot partition: ", reg);
> +       switch ((reg & EXT_CSD_BOOT_CFG_EN)>>3) {
> +       case 0x0:
> +               printf("disabled\n");
> +               break;
> +       case 0x1:
> +               printf("1\n");
> +               break;
> +       case 0x2:
> +               printf("2\n");
> +               break;
> +       case 0x7:
> +               printf("user area\n");
> +               break;
> +       }
> +}
> +
>  static int get_wp_group_size_in_blks(__u8 *ext_csd, __u32 *size)  {
>         __u8 ext_csd_rev = ext_csd[EXT_CSD_REV]; @@ -602,6 +625,37 @@ int
> do_disable_512B_emulation(int nargs, char **argv)
>         return ret;
>  }
> 
> +int do_read_boot_en(int nargs, char **argv) {
> +       __u8 ext_csd[512];
> +       int fd, ret;
> +       char *device;
> +
> +       if (nargs != 2) {
> +               fprintf(stderr, "Usage: mmc bootpart read </path/to/mmcblkX>\n");
> +               exit(1);
> +       }
> +
> +       device = argv[1];
> +
> +       fd = open(device, O_RDWR);
> +       if (fd < 0) {
> +               perror("open");
> +               exit(1);
> +       }
> +
> +       ret = read_extcsd(fd, ext_csd);
> +       if (ret) {
> +               fprintf(stderr, "Could not read EXT_CSD from %s\n", device);
> +               exit(1);
> +       }
> +
> +       print_boot_en_status(ext_csd);
> +
> +       close(fd);
> +       return ret;
> +}
> +
>  int do_write_boot_en(int nargs, char **argv)  {
>         __u8 ext_csd[512];
> diff --git a/mmc_cmds.h b/mmc_cmds.h
> index 5f2bef1..12716b5 100644
> --- a/mmc_cmds.h
> +++ b/mmc_cmds.h
> @@ -25,6 +25,7 @@ int do_writeprotect_boot_set(int nargs, char **argv);  int
> do_writeprotect_user_get(int nargs, char **argv);  int
> do_writeprotect_user_set(int nargs, char **argv);  int
> do_disable_512B_emulation(int nargs, char **argv);
> +int do_read_boot_en(int nargs, char **argv);
>  int do_write_boot_en(int nargs, char **argv);  int
> do_boot_bus_conditions_set(int nargs, char **argv);  int do_write_bkops_en(int
> nargs, char **argv);
> --
> 2.34.1
> 
> 
> ________________________________
> The information contained in this message may be confidential and legally
> protected under applicable law. The message is intended solely for the
> addressee(s). If you are not the intended recipient, you are hereby notified that
> any use, forwarding, dissemination, or reproduction of this message is strictly
> prohibited and may be unlawful. If you are not the intended recipient, please
> contact the sender by return e-mail and destroy all copies of the original
> message.





[Index of Archives]     [Linux Memonry Technology]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux