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

Subversion Repositories igor

[/] [igor/] [trunk/] [avr/] [src/] [device.h] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 atypic
#ifndef _DEVICE_H_
2
#define _DEVICE_H_
3
 
4
#include "buf.h"
5
 
6
/* Different function types to be implemented by a device. */
7
typedef uint8_t igordev_read_fn_t(uint64_t, uint8_t *, uint8_t);
8
typedef uint8_t igordev_write_fn_t(uint64_t, uint8_t *, uint8_t);
9
typedef void    igordev_init_fn_t(void);
10
typedef void    igordev_deinit_fn_t(void);
11
typedef void    igordev_flush_fn_t(void);
12
typedef int8_t status_t;
13
 
14
/* An error occured during read/write */
15
#define IDEV_STATUS_ERROR       1
16
/* The last read/write was ok */
17
#define IDEV_STATUS_OK          2
18
/* The last interrupt was not handled due to overflow. */
19
#define IDEV_STATUS_OVERFLOW    3
20
/* The device will be handling an interrupt. */
21
#define IDEV_STATUS_INTR        4
22
/* The device is busy in main. */
23
#define IDEV_STATUS_BUSY        5
24
 
25
struct idev_mgmt {
26
        uint8_t irqenable;      /* Marks if device have irq enabled. */
27
        uint64_t baseaddr;      /* Base address of device. */
28
        uint64_t curaddr;       /* Marks current address to read/write from. */
29
        uint64_t size;          /* Marks max address to read/write from. */
30
};
31
 
32
/*
33
 * This is just a suggestion to what we may need. It will probably be extended
34
 * quite soon...
35
 */
36
struct igordev {
37
        /* Hardware initialization. */
38
        igordev_init_fn_t *init;
39
        /* Hardware deinit... */
40
        igordev_deinit_fn_t *deinit;
41
        /* Perform a read from the device. */
42
        igordev_read_fn_t *read;
43
        /* Perform a write to the device. */
44
        igordev_write_fn_t *write;
45
        /* Perform a flush of the devices output buffers. */
46
        igordev_flush_fn_t *flush;
47
 
48
        /* Status pointers to device status. */
49
        status_t write_status;
50
        status_t read_status;
51
 
52
        struct idev_mgmt imgmt;
53
 
54
        /* Identification register describing the device capabilities. */
55
        uint32_t id;
56
#define CAN_READ        0x01
57
#define CAN_WRITE       0x02
58
#define ADDR_READ       0x04
59
#define ADDR_WRITE      0x08
60
#define DEVTYPE_MASK    0xFF
61
#define DEVTYPE_OFFSET  0x04
62
 
63
/* Device types */
64
#define DEVTYPE_SERIAL  0
65
#define DEVTYPE_STORAGE 1
66
#define DEVTYPE_TERM    2
67
#define DEVTYPE_BOOT    3
68
 
69
        /* Private for device handler. */
70
        void *priv;
71
};
72
 
73
/* Device memory areas. */
74
#define DEVICES         0x00
75
#define CURDEV          0x01
76
#define CLI             0x02
77
#define SAI             0x03
78
#define INTRDEV         0x04
79
 
80
/* Device-specific. */
81
#define OBJECT          0x10
82
#define ADDR_L          0x11
83
#define ADDR_H          0x12
84
#define SIZE_L          0x13
85
#define SIZE_H          0x14
86
#define STATUS          0x15
87
#define IDENTIFICATION  0x16
88
#define IRQENABLE       0x17
89
 
90
/* Functions for initializing and selecting devices. */
91
void             device_init(void);
92
struct igordev  *device_select(uint8_t);
93
#endif /* !_DEVICE_H_ */

powered by: WebSVN 2.1.0

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