Statistics
| Branch: | Revision:

root / prex-0.9.0 / bsp / drv / include / ddi.h @ 03e9c04a

History | View | Annotate | Download (3.33 KB)

1
/*
2
 * Copyright (c) 2009, Kohsuke Ohtani
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 * 3. Neither the name of the author nor the names of any co-contributors
14
 *    may be used to endorse or promote products derived from this software
15
 *    without specific prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
 * SUCH DAMAGE.
28
 */
29

    
30
/*
31
 * ddi.h - Device Driver Interface
32
 */
33

    
34
#ifndef _DDI_H
35
#define _DDI_H
36

    
37
#include <types.h>
38
#include <sys/cdefs.h>
39
#include <sys/types.h>
40
#include <machine/stdarg.h>
41
#include <dki.h>
42
#include <busio.h>                /* bus_read/bus_write */
43

    
44
#ifdef DEBUG
45
#define ASSERT(exp) do { if (!(exp)) \
46
                             assert(__FILE__, __LINE__, #exp); } while (0)
47
#else
48
#define ASSERT(exp) ((void)0)
49
#endif
50

    
51

    
52
/*
53
 * I/O request packet
54
 */
55
struct irp {
56
        int        cmd;                /* I/O command */
57
        int        blkno;                /* block number */
58
        u_long        blksz;                /* block size */
59
        void        *buf;                /* I/O buffer */
60
        int        ntries;                /* retry count */
61
        int        error;                /* error status */
62
        struct event iocomp;        /* I/O completion event */
63
};
64

    
65
/*
66
 * I/O command
67
 */
68
#define IO_NONE                0
69
#define IO_READ                1
70
#define IO_WRITE        2
71
#define IO_FORMAT        3        /* not supported */
72
#define IO_CANCEL        4
73

    
74

    
75
__BEGIN_DECLS
76
void         driver_shutdown(void);
77
void         calibrate_delay(void);
78
void         delay_usec(u_long usec);
79

    
80
int         enodev(void);
81
int         nullop(void);
82

    
83
dma_t         dma_attach(int chan);
84
void         dma_detach(dma_t handle);
85
void         dma_setup(dma_t handle, void *addr, u_long count, int read);
86
void         dma_stop(dma_t handle);
87
void        *dma_alloc(size_t size);
88

    
89
long         atol(const char *str);
90
char        *strncpy(char *dest, const char *src, size_t count);
91
int         strncmp(const char *src, const char *tgt, size_t count);
92
size_t         strlcpy(char *dest, const char *src, size_t count);
93
size_t         strnlen(const char *str, size_t max);
94
void         *memcpy(void *dest, const void *src, size_t count);
95
void         *memset(void *dest, int ch, size_t count);
96

    
97
u_long         strtoul(const char *nptr, char **endptr, int base);
98

    
99
int         isalnum(int c);
100
int         isalpha(int c);
101
int         isblank(int c);
102
int         isupper(int c);
103
int         islower(int c);
104
int         isspace(int c);
105
int         isdigit(int c);
106
int         isxdigit(int c);
107
int         isprint(int c);
108

    
109
#ifdef DEBUG
110
void         assert(const char *, int, const char *);
111
#endif
112
__END_DECLS
113

    
114
#endif /* !_DDI_H */