diff options
Diffstat (limited to 'utils/nwztools/emmctools/nvp.h')
-rw-r--r-- | utils/nwztools/emmctools/nvp.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/utils/nwztools/emmctools/nvp.h b/utils/nwztools/emmctools/nvp.h new file mode 100644 index 0000000000..1eff36c19e --- /dev/null +++ b/utils/nwztools/emmctools/nvp.h | |||
@@ -0,0 +1,93 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2012 Amaury Pouly | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef __NVP_H__ | ||
22 | #define __NVP_H__ | ||
23 | |||
24 | #include <stdint.h> | ||
25 | #include <stdbool.h> | ||
26 | #include "misc.h" | ||
27 | |||
28 | #define NVP_AREA_LARGE_KIND 1 | ||
29 | #define NVP_AREA_SMALL_KIND 2 | ||
30 | |||
31 | #define NVP_SMALL_AREA_MAX_CLUSTER 128 | ||
32 | #define NVP_LARGE_AREA_MAX_CLUSTER 256 | ||
33 | #define NVP_AREA_TABLE_SIZE 512 | ||
34 | |||
35 | #define NVP_SECTOR_SIZE 512 | ||
36 | #define NVP_TABLE_SECTOR 16 | ||
37 | #define NVP_DATA_SECTOR_MIN 64 | ||
38 | #define NVP_DATA_SECTOR_MAX 32767 | ||
39 | #define NVP_SECTOR_PER_CLUSTER 16 | ||
40 | #define NVP_CLUSTER_SIZE (NVP_SECTOR_SIZE * NVP_SECTOR_PER_CLUSTER) | ||
41 | |||
42 | #define NVP_LARGE_AREA_SIZE NVP_CLUSTER_SIZE | ||
43 | #define NVP_SMALL_AREA_SIZE NVP_SECTOR_SIZE | ||
44 | |||
45 | struct nvp_zone_info_entry_t | ||
46 | { | ||
47 | int node; | ||
48 | int start; // in 4 unit | ||
49 | int count; // in 512 unit for kind 2 and in 8192 for kind 1 | ||
50 | int size; | ||
51 | int res0, res1, res2, res3; | ||
52 | const char *name; | ||
53 | }; | ||
54 | |||
55 | struct nvp_area_info_entry_t | ||
56 | { | ||
57 | int kind; | ||
58 | struct nvp_zone_info_entry_t *zone_info; | ||
59 | int nr_zones; | ||
60 | int res0, res1, res2, res3; | ||
61 | const char *name; | ||
62 | }; | ||
63 | |||
64 | struct nvp_node_info_t | ||
65 | { | ||
66 | int area; | ||
67 | int zone; | ||
68 | }; | ||
69 | |||
70 | #define NVP_NR_AREAS 16 | ||
71 | |||
72 | extern struct nvp_area_info_entry_t nvp_area_info[NVP_NR_AREAS]; | ||
73 | |||
74 | typedef int (*nvp_read_fn_t)(uint32_t offset, uint32_t size, void *buf); | ||
75 | |||
76 | int nvp_init(int nvp_size, nvp_read_fn_t read, bool debug); | ||
77 | struct nvp_node_info_t nvp_get_node_info(int node); | ||
78 | int nvp_get_node_size(int node); | ||
79 | const char *nvp_get_node_name(int node); | ||
80 | const char *nvp_get_area_name(int node); | ||
81 | int nvp_read_node(int node, int offset, void *buffer, int size); | ||
82 | |||
83 | int nvp_info(void); | ||
84 | |||
85 | int nvp_get_cluster_status(int cluster); | ||
86 | int nvp_set_cluster_status(int cluster, int status); | ||
87 | int nvp_get_sector_status(int sector); | ||
88 | int nvp_set_sector_status(int sector, int status); | ||
89 | int nvp_get_cluster_number(int shadow, int area, int zone, int index); | ||
90 | int nvp_get_sector_number(int shadow, int area, int zone, int index); | ||
91 | int nvp_read_data(int shadow, int area, int zone, int offset, void *buffer, int size); | ||
92 | |||
93 | #endif /* __NVP_H__ */ | ||