summaryrefslogtreecommitdiff
path: root/utils/nwztools/emmctools/nvp.h
diff options
context:
space:
mode:
Diffstat (limited to 'utils/nwztools/emmctools/nvp.h')
-rw-r--r--utils/nwztools/emmctools/nvp.h93
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
45struct 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
55struct 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
64struct nvp_node_info_t
65{
66 int area;
67 int zone;
68};
69
70#define NVP_NR_AREAS 16
71
72extern struct nvp_area_info_entry_t nvp_area_info[NVP_NR_AREAS];
73
74typedef int (*nvp_read_fn_t)(uint32_t offset, uint32_t size, void *buf);
75
76int nvp_init(int nvp_size, nvp_read_fn_t read, bool debug);
77struct nvp_node_info_t nvp_get_node_info(int node);
78int nvp_get_node_size(int node);
79const char *nvp_get_node_name(int node);
80const char *nvp_get_area_name(int node);
81int nvp_read_node(int node, int offset, void *buffer, int size);
82
83int nvp_info(void);
84
85int nvp_get_cluster_status(int cluster);
86int nvp_set_cluster_status(int cluster, int status);
87int nvp_get_sector_status(int sector);
88int nvp_set_sector_status(int sector, int status);
89int nvp_get_cluster_number(int shadow, int area, int zone, int index);
90int nvp_get_sector_number(int shadow, int area, int zone, int index);
91int nvp_read_data(int shadow, int area, int zone, int offset, void *buffer, int size);
92
93#endif /* __NVP_H__ */