Project

General

Profile

Statistics
| Revision:

root / lab4 / .minix-src / include / sys / flashio.h @ 14

History | View | Annotate | Download (3.28 KB)

1 13 up20180614
/*        $NetBSD: flashio.h,v 1.4 2011/06/28 20:49:43 ahoka Exp $        */
2
3
/*-
4
 * Copyright (c) 2011 Department of Software Engineering,
5
 *                      University of Szeged, Hungary
6
 * Copyright (c) 2011 Adam Hoka <ahoka@NetBSD.org>
7
 * Copyright (c) 2010 David Tengeri <dtengeri@inf.u-szeged.hu>
8
 * All rights reserved.
9
 *
10
 * This code is derived from software contributed to The NetBSD Foundation
11
 * by the Department of Software Engineering, University of Szeged, Hungary
12
 *
13
 * Redistribution and use in source and binary forms, with or without
14
 * modification, are permitted provided that the following conditions
15
 * are met:
16
 * 1. Redistributions of source code must retain the above copyright
17
 *    notice, this list of conditions and the following disclaimer.
18
 * 2. Redistributions in binary form must reproduce the above copyright
19
 *    notice, this list of conditions and the following disclaimer in the
20
 *    documentation and/or other materials provided with the distribution.
21
 *
22
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32
 * SUCH DAMAGE.
33
 */
34
35
#ifndef _FLASHIO_H_
36
#define _FLASHIO_H_
37
38
#include <sys/ioctl.h>
39
40
/* this header may be used fron the kernel */
41
#if defined(_KERNEL) || defined(_STANDALONE)
42
#include <sys/types.h>
43
#else
44
#include <stdint.h>
45
#include <stdbool.h>
46
#endif
47
48
enum {
49
        FLASH_ERASE_DONE         = 0x0,
50
        FLASH_ERASE_FAILED        = 0x1
51
};
52
53
enum {
54
        FLASH_TYPE_UNKNOWN        = 0x0,
55
        FLASH_TYPE_NOR                = 0x1,
56
        FLASH_TYPE_NAND                = 0x2
57
};
58
59
/* public userspace API */
60
61
/* common integer type to address flash */
62
typedef int64_t flash_off_t;
63
typedef uint64_t flash_size_t;
64
typedef uint64_t flash_addr_t;
65
66
/**
67
 * struct erase_params - for ioctl erase call
68
 * @addr: start address of the erase
69
 * @len: length of the erase
70
 */
71
struct flash_erase_params {
72
        flash_off_t ep_addr;
73
        flash_off_t ep_len;
74
};
75
76
struct flash_badblock_params {
77
        flash_off_t bbp_addr;
78
        bool bbp_isbad;
79
};
80
81
struct flash_info_params {
82
        flash_off_t ip_flash_size;
83
        flash_size_t ip_page_size;
84
        flash_size_t ip_erase_size;
85
        uint8_t ip_flash_type;
86
};
87
88
struct flash_dump_params {
89
        flash_off_t dp_block;
90
        flash_off_t dp_len;
91
        uint8_t *dp_buf;
92
};
93
94
enum {
95
        FLASH_IOCTL_ERASE_BLOCK,
96
        FLASH_IOCTL_DUMP,
97
        FLASH_IOCTL_GET_INFO,
98
        FLASH_IOCTL_BLOCK_ISBAD,
99
        FLASH_IOCTL_BLOCK_MARKBAD
100
};
101
102
#define FLASH_ERASE_BLOCK         \
103
        _IOW('&', FLASH_IOCTL_ERASE_BLOCK, struct flash_erase_params)
104
105
#define FLASH_DUMP                \
106
        _IOWR('&', FLASH_IOCTL_DUMP, struct flash_dump_params)
107
108
#define FLASH_GET_INFO                \
109
        _IOWR('&', FLASH_IOCTL_GET_INFO, struct flash_info_params)
110
111
#define FLASH_BLOCK_ISBAD         \
112
        _IOWR('&', FLASH_IOCTL_BLOCK_ISBAD, struct flash_badblock_params)
113
114
#define FLASH_BLOCK_MARKBAD        \
115
        _IOW('&', FLASH_IOCTL_BLOCK_MARKBAD, struct flash_badblock_params)
116
117
#endif