Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/storage/emmc.h
1476 views
1
/*
2
* Copyright (c) 2018 naehrwert
3
* Copyright (c) 2019-2022 CTCaer
4
*
5
* This program is free software; you can redistribute it and/or modify it
6
* under the terms and conditions of the GNU General Public License,
7
* version 2, as published by the Free Software Foundation.
8
*
9
* This program is distributed in the hope it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef _EMMC_H_
19
#define _EMMC_H_
20
21
#include <storage/sdmmc.h>
22
#include <utils/types.h>
23
#include <utils/list.h>
24
25
#include <libs/fatfs/ff.h>
26
27
#define GPT_FIRST_LBA 1
28
#define GPT_NUM_BLOCKS 33
29
#define EMMC_BLOCKSIZE SDMMC_DAT_BLOCKSIZE
30
31
enum
32
{
33
EMMC_INIT_FAIL = 0,
34
EMMC_1BIT_HS52 = 1,
35
EMMC_8BIT_HS52 = 2,
36
EMMC_MMC_HS200 = 3,
37
EMMC_MMC_HS400 = 4,
38
};
39
40
enum
41
{
42
EMMC_ERROR_INIT_FAIL = 0,
43
EMMC_ERROR_RW_FAIL = 1,
44
EMMC_ERROR_RW_RETRY = 2
45
};
46
47
typedef struct _emmc_part_t
48
{
49
u32 index;
50
u32 lba_start;
51
u32 lba_end;
52
u64 attrs;
53
char name[37];
54
link_t link;
55
} emmc_part_t;
56
57
extern sdmmc_t emmc_sdmmc;
58
extern sdmmc_storage_t emmc_storage;
59
extern FATFS emmc_fs;
60
61
void emmc_error_count_increment(u8 type);
62
u16 *emmc_get_error_count();
63
u32 emmc_get_mode();
64
int emmc_init_retry(bool power_cycle);
65
bool emmc_initialize(bool power_cycle);
66
int emmc_set_partition(u32 partition);
67
void emmc_end();
68
69
void emmc_gpt_parse(link_t *gpt);
70
void emmc_gpt_free(link_t *gpt);
71
emmc_part_t *emmc_part_find(link_t *gpt, const char *name);
72
int emmc_part_read(emmc_part_t *part, u32 sector_off, u32 num_sectors, void *buf);
73
int emmc_part_write(emmc_part_t *part, u32 sector_off, u32 num_sectors, void *buf);
74
75
void nx_emmc_get_autorcm_masks(u8 *mod0, u8 *mod1);
76
77
#endif
78
79