forked from xerub/ibex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nand.h
118 lines (105 loc) · 3.14 KB
/
nand.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
* ibex - nand-related stuff
*
* Copyright (c) 2015 xerub
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NAND_H_included
#define NAND_H_included
struct bdev6_t {
struct bdev6_t *next;
unsigned field_4;
unsigned field_8;
unsigned field_C;
unsigned field_10;
unsigned size_lo;
unsigned size_hi;
int (*bdev_read)(void *bdev, void *buf, long long offset, long long size);
unsigned block_read;
unsigned bdev_write;
unsigned block_write;
unsigned field_34;
char name[16];
} /*__attribute__((packed))*/;
struct bdev_t {
struct bdev_t *next;
unsigned field_4;
unsigned field_8;
unsigned field_C;
unsigned field_10;
unsigned size_lo;
unsigned size_hi;
unsigned field_1C;
unsigned field_20;
int (*bdev_read)(void *bdev, void *buf, long long offset, long long size);
unsigned block_read;
unsigned bdev_write;
unsigned block_write;
unsigned field_34;
char name[16];
unsigned field_48;
unsigned field_4C;
unsigned field_50;
unsigned field_54;
} /*__attribute__((packed))*/;
struct firmware_image;
struct firmware_image_info {
unsigned total_length;
unsigned size;
unsigned type;
unsigned magic;
unsigned flags;
struct firmware_image *super;
} /*__attribute__((packed))*/;
struct firmware_image {
struct firmware_image *prev;
struct firmware_image *next;
struct bdev_t *bdev;
unsigned offset_lo;
unsigned offset_hi;
unsigned field_14;
struct firmware_image_info info;
} /*__attribute__((packed))*/;
typedef unsigned int (*h2fmi_getattr_t)(int attr);
typedef int (*h2fmi_read_single_page_t)(short ce, int page, void *where, void *meta_ptr, char *ecc_out, char *ecc_ptr, int unencrypted);
typedef int (*h2fmi_read_boot_page_t)(short ce, int page, void *where);
typedef struct {
unsigned int u0;
h2fmi_read_single_page_t read_single_page;
unsigned int u2;
unsigned int u3;
unsigned int u4;
unsigned int u5;
h2fmi_read_boot_page_t read_boot_page;
unsigned int u7;
unsigned int u8;
unsigned int u9;
unsigned int u10;
unsigned int u11;
unsigned int u12;
unsigned int u13;
unsigned int u14;
unsigned int u15;
unsigned int u16;
unsigned int u17;
unsigned int u18;
unsigned int u19;
h2fmi_getattr_t get_attr;
/* ... */
} h2fmi_t;
int read_llb(h2fmi_read_boot_page_t read_page, int offset, int size, unsigned char *buf);
int bdev_read(void *bdev, void *buf, long long offset, long long size);
const char *bdev_name(void *bdev);
#endif