Skip to content

Commit 8a53dad

Browse files
committed
rename chan to chan_out in libchan
1 parent 9241eb9 commit 8a53dad

File tree

6 files changed

+91
-91
lines changed

6 files changed

+91
-91
lines changed

cxip/cxip.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
uint8_t xxx_buf[MSG_BUF_SIZE];
2525
size_t xxx_buf_len = 0;
2626

27-
bool serve(int listen_sock, struct chan *chan);
28-
void handle_client(int sock, struct chan *chan);
29-
void handle_message(int sock, struct chan *chan, uint8_t *msg, size_t msg_len);
30-
void test_and_send_status(int sock, struct chan *chan, uint8_t addr);
31-
void purge_status(struct chan *chan, uint8_t addr);
27+
bool serve(int listen_sock, struct chan_out *chan);
28+
void handle_client(int sock, struct chan_out *chan);
29+
void handle_message(int sock, struct chan_out *chan, uint8_t *msg, size_t msg_len);
30+
void test_and_send_status(int sock, struct chan_out *chan, uint8_t addr);
31+
void purge_status(struct chan_out *chan, uint8_t addr);
3232

3333
int main(int argc, char **argv)
3434
{
@@ -74,9 +74,9 @@ int main(int argc, char **argv)
7474
printf("WARN: External interface not enabled, acting as loopback\n");
7575
}
7676

77-
struct chan chan;
77+
struct chan_out chan;
7878

79-
if (chan_open(&chan, 0x40000000, mem_fd, "udmabuf0", frontend_enable) < 0) {
79+
if (chan_out_open(&chan, 0x40000000, mem_fd, "udmabuf0", frontend_enable) < 0) {
8080
perror("chan_open");
8181
return EXIT_FAILURE;
8282
}
@@ -95,15 +95,15 @@ int main(int argc, char **argv)
9595
}
9696

9797
mock_cu_close(&mock_cu);
98-
chan_close(&chan, true);
98+
chan_out_close(&chan, true);
9999

100100
close(listen_sock);
101101
close(mem_fd);
102102

103103
return EXIT_SUCCESS;
104104
}
105105

106-
bool serve(int listen_sock, struct chan *chan)
106+
bool serve(int listen_sock, struct chan_out *chan)
107107
{
108108
int epfd;
109109

@@ -183,7 +183,7 @@ purge_status(chan, ADDR);
183183

184184
// Check for request in.
185185
if (client_sock != -1) {
186-
if (chan_request_in(chan)) {
186+
if (chan_out_request_in(chan)) {
187187
printf("REQUEST IN...\n");
188188

189189
test_and_send_status(client_sock, chan, ADDR /* TODO */);
@@ -194,7 +194,7 @@ purge_status(chan, ADDR);
194194
return true;
195195
}
196196

197-
void handle_client(int sock, struct chan *chan)
197+
void handle_client(int sock, struct chan_out *chan)
198198
{
199199
// First, read as much as we can into the buffer.
200200
uint8_t *buf_p = xxx_buf + xxx_buf_len;
@@ -251,7 +251,7 @@ void handle_client(int sock, struct chan *chan)
251251
}
252252
}
253253

254-
void handle_message(int sock, struct chan *chan, uint8_t *msg, size_t msg_len)
254+
void handle_message(int sock, struct chan_out *chan, uint8_t *msg, size_t msg_len)
255255
{
256256
uint8_t buf[MSG_BUF_SIZE];
257257

@@ -296,9 +296,9 @@ void handle_message(int sock, struct chan *chan, uint8_t *msg, size_t msg_len)
296296

297297
printf("\taddr = %.2x, cmd = %.2x, flags = %.2x, count = %zu\n", addr, cmd, flags, count);
298298

299-
ssize_t result = chan_exec(chan, ADDR /* TODO */, cmd, data, count);
299+
ssize_t result = chan_out_exec(chan, ADDR /* TODO */, cmd, data, count);
300300

301-
uint8_t device_status = chan_device_status(chan);
301+
uint8_t device_status = chan_out_device_status(chan);
302302

303303
/*
304304
ssize_t result;
@@ -339,18 +339,18 @@ void handle_message(int sock, struct chan *chan, uint8_t *msg, size_t msg_len)
339339
// wait for it via request in...
340340
printf("\tgot CE without DE, waiting for DE via request in...\n");
341341

342-
while (!chan_request_in(chan)) {
342+
while (!chan_out_request_in(chan)) {
343343
usleep(100000); // 100ms
344344
}
345345

346-
int test_result = chan_test(chan, ADDR /* TODO */);
346+
int test_result = chan_out_test(chan, ADDR /* TODO */);
347347

348348
if (test_result < 0) {
349349
printf("\ttest result = %d\n", test_result);
350350
return;
351351
}
352352

353-
device_status |= chan_device_status(chan);
353+
device_status |= chan_out_device_status(chan);
354354

355355
printf("\tupdated status = %.2x\n", device_status);
356356

@@ -388,18 +388,18 @@ void handle_message(int sock, struct chan *chan, uint8_t *msg, size_t msg_len)
388388
}
389389
}
390390

391-
void test_and_send_status(int sock, struct chan *chan, uint8_t addr)
391+
void test_and_send_status(int sock, struct chan_out *chan, uint8_t addr)
392392
{
393393
uint8_t buf[MSG_BUF_SIZE];
394394

395-
int result = chan_test(chan, addr);
395+
int result = chan_out_test(chan, addr);
396396

397397
if (result < 0) {
398398
printf("\tresult = %d\n", result);
399399
return;
400400
}
401401

402-
uint8_t device_status = chan_device_status(chan);
402+
uint8_t device_status = chan_out_device_status(chan);
403403

404404
printf("\tstatus = %.2x\n", device_status);
405405

@@ -414,20 +414,20 @@ void test_and_send_status(int sock, struct chan *chan, uint8_t addr)
414414
}
415415
}
416416

417-
void purge_status(struct chan *chan, uint8_t addr)
417+
void purge_status(struct chan_out *chan, uint8_t addr)
418418
{
419419
// Very hacky... this is no way to do error recovery!
420420
while (true) {
421421
printf("TEST...\n");
422422

423-
int result = chan_test(chan, addr);
423+
int result = chan_out_test(chan, addr);
424424

425425
if (result < 0) {
426426
printf("\tresult = %d\n", result);
427427
return;
428428
}
429429

430-
uint8_t status = chan_device_status(chan);
430+
uint8_t status = chan_out_device_status(chan);
431431

432432
printf("\tstatus = 0x%.2x\n", status);
433433

libchan/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CFLAGS = -Wall -I../libhack
22

33
all: libchan.a test_3174 test_mock test_wrap
44

5-
libchan.a: chan.o mock_cu.o
5+
libchan.a: chan_out.o mock_cu.o
66
$(AR) rcs $@ $^
77

88
test_3174: test_3174.c libchan.a ../libhack/libhack.a

libchan/chan.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@
1616
#define CHAN_STATUS_UC 0x02 // Unit Check
1717
#define CHAN_STATUS_UX 0x01 // Unit Exception
1818

19-
struct chan {
19+
struct chan_out {
2020
uintptr_t addr;
2121
void *base;
2222
volatile uint32_t *regs;
2323
struct udmabuf udmabuf;
2424
};
2525

26-
int chan_open(struct chan *chan, uintptr_t addr, int mem_fd, char *udmabuf_path, bool frontend_enable);
26+
int chan_out_open(struct chan_out *chan, uintptr_t addr, int mem_fd, char *udmabuf_path, bool frontend_enable);
2727

28-
int chan_close(struct chan *chan, bool disable);
28+
int chan_out_close(struct chan_out *chan, bool disable);
2929

30-
int chan_test(struct chan *chan, uint8_t addr);
30+
int chan_out_test(struct chan_out *chan, uint8_t addr);
3131

32-
ssize_t chan_exec(struct chan *chan, uint8_t addr, uint8_t cmd, uint8_t *buf, size_t count);
32+
ssize_t chan_out_exec(struct chan_out *chan, uint8_t addr, uint8_t cmd, uint8_t *buf, size_t count);
3333

34-
uint8_t chan_device_status(struct chan *chan);
34+
uint8_t chan_out_device_status(struct chan_out *chan);
3535

36-
bool chan_request_in(struct chan *chan);
36+
bool chan_out_request_in(struct chan_out *chan);
3737

3838
#endif

libchan/chan.c renamed to libchan/chan_out.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
#define REG_CCW_1 4
1919
#define REG_CCW_2 5
2020

21-
void config(struct chan *chan, bool enable, bool frontend_enable);
21+
void config(struct chan_out *chan, bool enable, bool frontend_enable);
2222
static inline bool is_read_cmd(uint8_t cmd);
2323
static inline bool is_write_cmd(uint8_t cmd);
2424

25-
int chan_open(struct chan *chan, uintptr_t addr, int mem_fd, char *udmabuf_path, bool frontend_enable)
25+
int chan_out_open(struct chan_out *chan, uintptr_t addr, int mem_fd, char *udmabuf_path, bool frontend_enable)
2626
{
2727
chan->addr = addr;
2828

@@ -43,7 +43,7 @@ int chan_open(struct chan *chan, uintptr_t addr, int mem_fd, char *udmabuf_path,
4343
return 0;
4444
}
4545

46-
int chan_close(struct chan *chan, bool disable)
46+
int chan_out_close(struct chan_out *chan, bool disable)
4747
{
4848
if (chan == NULL) {
4949
return 0;
@@ -66,7 +66,7 @@ int chan_close(struct chan *chan, bool disable)
6666
return result;
6767
}
6868

69-
int chan_test(struct chan *chan, uint8_t addr)
69+
int chan_out_test(struct chan_out *chan, uint8_t addr)
7070
{
7171
// Channel is active...
7272
if (chan->regs[REG_STATUS_1] & 0x01) {
@@ -91,7 +91,7 @@ int chan_test(struct chan *chan, uint8_t addr)
9191
return 0;
9292
}
9393

94-
ssize_t chan_exec(struct chan *chan, uint8_t addr, uint8_t cmd, uint8_t *buf, size_t count)
94+
ssize_t chan_out_exec(struct chan_out *chan, uint8_t addr, uint8_t cmd, uint8_t *buf, size_t count)
9595
{
9696
if (count > 0 && buf == NULL) {
9797
return -1;
@@ -129,7 +129,7 @@ ssize_t chan_exec(struct chan *chan, uint8_t addr, uint8_t cmd, uint8_t *buf, si
129129
return -3;
130130
}
131131

132-
uint8_t device_status = chan_device_status(chan);
132+
uint8_t device_status = chan_out_device_status(chan);
133133

134134
if (device_status & CHAN_STATUS_BUSY) {
135135
return -4;
@@ -155,17 +155,17 @@ ssize_t chan_exec(struct chan *chan, uint8_t addr, uint8_t cmd, uint8_t *buf, si
155155
return actual_count;
156156
}
157157

158-
uint8_t chan_device_status(struct chan *chan)
158+
uint8_t chan_out_device_status(struct chan_out *chan)
159159
{
160160
return (uint8_t) (chan->regs[REG_STATUS_2] >> 24);
161161
}
162162

163-
bool chan_request_in(struct chan *chan)
163+
bool chan_out_request_in(struct chan_out *chan)
164164
{
165165
return chan->regs[REG_STATUS_1] & 0x02;
166166
}
167167

168-
void config(struct chan *chan, bool enable, bool frontend_enable)
168+
void config(struct chan_out *chan, bool enable, bool frontend_enable)
169169
{
170170
chan->regs[REG_CONTROL_1] = (frontend_enable << 31) | (enable << 1);
171171
}

0 commit comments

Comments
 (0)