OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [branches/] [stable_0_1_x/] [or1ksim/] [peripheral/] [channels/] [channel.h] - Blame information for rev 1771

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1070 rprescott
/* channel.h -- Definition of types and structures for
2
   peripheral to communicate with host.  Addapted from UML.
3
 
4
   Copyright (C) 2002 Richard Prescott <rip@step.polymtl.ca>
5
 
6
This file is part of OpenRISC 1000 Architectural Simulator.
7
 
8
This program is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 2 of the License, or
11
(at your option) any later version.
12
 
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
GNU General Public License for more details.
17
 
18
You should have received a copy of the GNU General Public License
19
along with this program; if not, write to the Free Software
20
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21
 
22
#ifndef CHANNEL_H
23
#define CHANNEL_H
24
 
25
struct channel_ops
26
{
27
        void *(*init)(const char *);
28
        int (*open)(void *);
29
        void (*close)(void *);
30
        int (*read)(void *, char *, int);
31
        int (*write)(void *, const char *, int);
32
        void (*free)(void *);
33
        int (*isok)(void*);
34
        char* (*status)(void*);
35
};
36
 
37
struct channel
38
{
39
        const struct channel_ops * ops;
40
        void * data;
41
};
42
 
43
 
44
struct channel * channel_init(const char * descriptor);
45
/* read operation in non-blocking */
46
int channel_open(struct channel * channel);
47
int channel_read(struct channel * channel, char * buffer, int size);
48
int channel_write(struct channel * channel, const char * buffer, int size);
49
void channel_free(struct channel * channel);
50
int channel_ok(struct channel * channel);
51
char * channel_status(struct channel * channel);
52
 
53
void channel_close(struct channel * channel);
54
 
55
int register_channel(const char * name, const struct channel_ops * ops);
56
/* TODO: int unregister_channel(const char * name); */
57
 
58
/* for those who wants to automatically register at startup */
59
#define REGISTER_CHANNEL(NAME,OPS) \
60
  static int NAME ## _dummy_register = register_channel(#NAME, OPS)
61
 
62
#endif
63
 
64
/*
65
 * Local variables:
66
 * c-file-style: "linux"
67
 * End:
68
 */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.