1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
/*
* Copyright 2014 Broadcom Corporation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2, as
* published by the Free Software Foundation (the "GPL").
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* A copy of the GPL is available at
* http://www.broadcom.com/licenses/GPLv2.php, or by writing to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* The BBD (Broadcom Bridge Driver)
*
* tabstop = 8
*/
#include "bbd_internal.h"
#include "transport/bbd_engine.h"
#include "transport/bbd_bridge_c.h"
/**
* initialize sio-specific variables
*
* @pbbd_dev: bbd driver pointer
*
* @return: 0 = success, others = failure
*/
void bbd_sio_init_vars(struct bbd_device *dev, int* result)
{
struct bbd_sio_device *p = 0;
if (*result)
return;
p = bbd_alloc(sizeof(struct bbd_sio_device));
if (!p) {
*result = -ENOMEM;
return;
}
bbd_base_init_vars(dev, &p->base, result);
if (*result) {
bbd_free(p);
return;
}
dev->bbd_ptr[BBD_MINOR_SIO] = p;
p->base.name = "sio";
}
struct bbd_sio_device* bbd_sio_ptr(void)
{
if (!gpbbd_dev)
return 0;
return gpbbd_dev->bbd_ptr[BBD_MINOR_SIO];
}
struct bbd_base* bbd_sio_ptr_base(void)
{
struct bbd_sio_device *p = bbd_sio_ptr();
if (!p)
return 0;
return &p->base;
}
int bbd_sio_uninit(void)
{
struct bbd_sio_device* p = bbd_sio_ptr();
int freed = 0;
if (p) {
freed = bbd_base_uninit(&p->base);
bbd_free(p);
gpbbd_dev->bbd_ptr[BBD_MINOR_SIO] = 0;
}
return freed;
}
/* We are passed a pointer to the bridge
* if we're active, zero otherwise
* Could consider a pass-thru flag
* from /dev/bbd_control for testing.
*/
void bbd_sio_install(struct BbdBridge* bbd)
{
FUNC();
}
/**
* open bbd driver
*/
int bbd_sio_open(struct inode *inode, struct file *filp)
{
dprint(KERN_INFO "BBD:%s()\n", __func__);
if (!gpbbd_dev)
return -EFAULT;
filp->private_data = gpbbd_dev;
return 0;
}
/**
* close bbd driver
*/
int bbd_sio_release(struct inode *inode, struct file *filp)
{
if (!gpbbd_dev)
return -EFAULT;
return bbd_base_reinit(BBD_MINOR_SIO);
}
/**
* read signal/data from bbd_list_head to user
*/
ssize_t bbd_sio_read(struct file *filp,
char __user *buf,
size_t size, loff_t *ppos)
{
return bbd_read(BBD_MINOR_SIO, buf, size, true);
}
/**
* send data from user space to external driver
*/
ssize_t bbd_sio_write(struct file *filp,
const char __user *buf,
size_t size, loff_t *ppos)
{
ssize_t len = bbd_write(BBD_MINOR_SIO, buf, size, true);
if (len != size)
return len;
// if (gpbbd_dev->sio_dummy) // assume this until the sub-driver is
// // ready.
{
struct BbdEngine* pEng = bbd_engine();
struct BbdBridge* bbd = 0;
if (pEng) {
bbd = &pEng->bridge;
BbdBridge_SetData(bbd, buf, size);
}
else
len = -EINVAL;
}
// else
// {
// tickle the sub-device driver to send data?
// }
return len;
}
/**
* this function is for tx sio
*/
unsigned int bbd_sio_poll(struct file *filp, poll_table * wait)
{
return bbd_poll(BBD_MINOR_SIO, filp, wait);
}
|