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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [sw/] [devbus.h] - Blame information for rev 5

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

Line No. Rev Author Line
1 5 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    devbus.h
4
//
5
// Project:     XuLA2 board
6
//
7
// Purpose:     The purpose of this file is to document an interface which
8
//              any device with a bus, whether it be implemented over a UART,
9
//      an ethernet, or a PCI express bus, must implement.  This describes
10
//      only an interface, and not how that interface is to be accomplished.
11
//
12
//      The neat part of this interface is that, if programs are designed to
13
//      work with it, than the implementation details may be changed later
14
//      and any program that once worked with the interface should be able
15
//      to continue to do so.  (i.e., switch from a UART controlled bus to a
16
//      PCI express controlled bus, with minimal change to the software of
17
//      interest.)
18
//
19
//
20
// Creator:     Dan Gisselquist, Ph.D.
21
//              Gisselquist Technology, LLC
22
//
23
////////////////////////////////////////////////////////////////////////////////
24
//
25
// Copyright (C) 2015, Gisselquist Technology, LLC
26
//
27
// This program is free software (firmware): you can redistribute it and/or
28
// modify it under the terms of  the GNU General Public License as published
29
// by the Free Software Foundation, either version 3 of the License, or (at
30
// your option) any later version.
31
//
32
// This program is distributed in the hope that it will be useful, but WITHOUT
33
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
34
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
35
// for more details.
36
//
37
// License:     GPL, v3, as defined and found on www.gnu.org,
38
//              http://www.gnu.org/licenses/gpl.html
39
//
40
//
41
////////////////////////////////////////////////////////////////////////////////
42
//
43
//
44
//
45
#ifndef DEVBUS_H
46
#define DEVBUS_H
47
 
48
#include <stdio.h>
49
#include <unistd.h>
50
 
51
typedef unsigned int    uint32;
52
 
53
class   BUSERR {
54
public:
55
        uint32 addr;
56
        BUSERR(const uint32 a) : addr(a) {};
57
};
58
 
59
class   DEVBUS {
60
public:
61
        typedef uint32  BUSW;
62
 
63
        virtual void    kill(void) = 0;
64
        virtual void    close(void) = 0;
65
 
66
        // Write a single value to a single address
67
        virtual void    writeio(const BUSW a, const BUSW v) = 0;
68
 
69
        // Read a single value to a single address
70
        virtual BUSW    readio(const BUSW a) = 0;
71
 
72
        // Read a series of values from values from a block of memory
73
        virtual void    readi(const BUSW a, const int len, BUSW *buf) = 0;
74
 
75
        // Read a series of values from the same address in memory
76
        virtual void    readz(const BUSW a, const int len, BUSW *buf) = 0;
77
 
78
        virtual void    writei(const BUSW a, const int len, const BUSW *buf) = 0;
79
        virtual void    writez(const BUSW a, const int len, const BUSW *buf) = 0;
80
 
81
        // Query whether or not an interrupt has taken place
82
        virtual bool    poll(void) = 0;
83
 
84
        // Sleep until interrupt, but sleep no longer than msec milliseconds
85
        virtual void    usleep(unsigned msec) = 0;
86
 
87
        // Sleep until an interrupt, no matter how long it takes for that
88
        // interrupt to take place
89
        virtual void    wait(void) = 0;
90
 
91
        // Query whether or not a bus error has taken place.  This is somewhat
92
        // of a misnomer, as my current bus error detection code exits any
93
        // interface, but ... it is what it is.
94
        virtual bool    bus_err(void) const = 0;
95
 
96
        // Clear any bus error condition.
97
        virtual void    reset_err(void) = 0;
98
 
99
        // Clear any interrupt condition that has already been noticed by
100
        // the interface, does not check for further interrupt
101
        virtual void    clear(void) = 0;
102
 
103
        virtual ~DEVBUS(void) { };
104
};
105
 
106
#endif

powered by: WebSVN 2.1.0

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