change source file mode to 0644 instead of 0755
[profile/mobile/platform/kernel/u-boot-tm1.git] / property / recv_emc_mode.c
1 #include <common.h>
2 #include <android_recovery.h>
3 #include "../drivers/mmc/card_sdio.h"
4 #include "asm/arch/sci_types.h"
5 #include "normal_mode.h"
6
7 static char buf[8192];
8
9 int get_recovery_message(struct recovery_message *out)
10 {
11         block_dev_desc_t *p_block_dev = NULL;
12         disk_partition_t info;
13         int size=8192;
14         p_block_dev = get_dev("mmc", 1);
15         if(NULL == p_block_dev){
16                 return -1;
17         }
18         if (!get_partition_info_by_name(p_block_dev, L"misc", &info)) {
19                 if(TRUE !=  Emmc_Read(PARTITION_USER, info.start, size/EMMC_SECTOR_SIZE, (void *)buf)){
20                         debugf("function: %s emcc read error\n", __FUNCTION__);
21                         return -1;
22                 }
23         }
24
25         memcpy(out, buf, sizeof(*out));
26         return 0;
27 }
28
29 int set_recovery_message(const struct recovery_message *in)
30 {
31         block_dev_desc_t *p_block_dev = NULL;
32         disk_partition_t info;
33         int size=8192;
34         p_block_dev = get_dev("mmc", 1);
35         if(NULL == p_block_dev){
36                 return -1;
37         }
38         if (!get_partition_info_by_name(p_block_dev, L"misc", &info)) {
39                 memset(buf, 0, sizeof(buf));
40                 if(TRUE !=  Emmc_Read(PARTITION_USER, info.start, size/EMMC_SECTOR_SIZE, (void *)buf)){
41                         debugf("function: %s emcc read error\n", __FUNCTION__);
42                         return -1;
43                 }
44                 memcpy((void *)buf, in, sizeof(*in));
45                 if(TRUE !=  Emmc_Write(PARTITION_USER, info.start, size/EMMC_SECTOR_SIZE, (void *)buf)){
46                         debugf("function: %s emcc write error\n", __FUNCTION__);
47                         return -1;
48                 }
49         }
50         return 0;
51 }