Date:2010-11-11 12:48:08 (9 years 1 month ago)
Author:Werner Almesberger
Commit:84b61f35f23de6d3735851388d0da8540a08a949
Message:The Great ATSPI Renaming, part 3: rename libatspi.a to libatrf.a

- tools/lib/atspi.c: renamed to atrf.c
- tools/lib/Makefile (OBJS): track above change
- tools/Makefile.common (LDLIBS), tools/lib/Makefile (LIB): rename the
whole library from libatspi to libatrf
Files: tools/Makefile.common (1 diff)
tools/lib/Makefile (2 diffs)
tools/lib/atrf.c (1 diff)
tools/lib/atspi.c (1 diff)

Change Details

tools/Makefile.common
4444
4545CFLAGS += $(CFLAGS_$(TARGET)) -I../../atusb/fw/include -I../include \
4646          $(MACROS_$(TARGET))
47LDLIBS = $(LDLIBS_$(TARGET)) -L../lib -latspi
47LDLIBS = $(LDLIBS_$(TARGET)) -L../lib -latrf
4848OBJS += $(OBJS_$(TARGET))
tools/lib/Makefile
11#
2# lib/Makefile - Build the ATSPI library
2# lib/Makefile - Build the ATRF library
33#
44# Written 2010 by Werner Almesberger
55# Copyright 2010 Werner Almesberger
...... 
1111#
1212
1313
14LIB = libatspi.a
14LIB = libatrf.a
1515
1616include ../Makefile.common
1717
1818CFLAGS += -Wall -I$(F32XBASE)/include
1919OBJS_host = atusb.o $(F32XBASE)/lib/usb.o
2020OBJS_ben = atusd.o
21OBJS = atspi.o misctxrx.o $(OBJS_$(TARGET))
21OBJS = atrf.o misctxrx.o $(OBJS_$(TARGET))
2222
2323.PHONY: all clean spotless
2424
tools/lib/atrf.c
1/*
2 * lib/atspi.c - ATSPI access functions library
3 *
4 * Written 2010 by Werner Almesberger
5 * Copyright 2010 Werner Almesberger
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13
14#include <stdlib.h>
15#include <stdio.h>
16
17#include "driver.h"
18#include "atspi.h"
19
20
21extern struct atspi_driver atusb_driver;
22extern struct atspi_driver atusd_driver;
23
24
25struct atspi_dsc {
26    struct atspi_driver *driver;
27    void *handle;
28};
29
30
31void *atspi_usb_handle(struct atspi_dsc *dsc)
32{
33#ifdef HAVE_USB
34    return dsc->handle;
35#else
36    return NULL;
37#endif
38}
39
40
41int atspi_error(struct atspi_dsc *dsc)
42{
43    return dsc->driver->error ? dsc->driver->error(dsc->handle) : 0;
44}
45
46
47int atspi_clear_error(struct atspi_dsc *dsc)
48{
49    return dsc->driver->clear_error ?
50        dsc->driver->clear_error(dsc->handle) : 0;
51}
52
53
54struct atspi_dsc *atspi_open(void)
55{
56    struct atspi_dsc *dsc;
57    struct atspi_driver *driver;
58    void *handle;
59
60#ifdef HAVE_USB
61    driver = &atusb_driver;
62#elif HAVE_USD
63    driver = &atusd_driver;
64#else
65#error Need either HAVE_USB or HAVE_USD
66#endif
67    handle = driver->open();
68    if (!handle)
69        return NULL;
70    dsc = malloc(sizeof(*dsc));
71    if (!dsc) {
72        perror("malloc");
73        exit(1);
74    }
75    dsc->driver = driver;
76    dsc->handle = handle;
77    return dsc;
78}
79
80
81void atspi_close(struct atspi_dsc *dsc)
82{
83    if (dsc->driver->close)
84        dsc->driver->close(dsc->handle);
85    free(dsc);
86}
87
88
89void atspi_reset(struct atspi_dsc *dsc)
90{
91    if (dsc->driver->reset)
92        dsc->driver->reset(dsc->handle);
93}
94
95
96void atspi_reset_rf(struct atspi_dsc *dsc)
97{
98    dsc->driver->reset_rf(dsc->handle);
99}
100
101
102int atspi_test_mode(struct atspi_dsc *dsc)
103{
104    if (!dsc->driver->test_mode)
105        return 0;
106    dsc->driver->test_mode(dsc->handle);
107    return 1;
108}
109
110
111void atspi_reg_write(struct atspi_dsc *dsc, uint8_t reg, uint8_t value)
112{
113    dsc->driver->reg_write(dsc->handle, reg, value);
114}
115
116
117uint8_t atspi_reg_read(struct atspi_dsc *dsc, uint8_t reg)
118{
119    return dsc->driver->reg_read(dsc->handle, reg);
120}
121
122
123void atspi_buf_write(struct atspi_dsc *dsc, const void *buf, int size)
124{
125    dsc->driver->buf_write(dsc->handle, buf, size);
126}
127
128
129int atspi_buf_read(struct atspi_dsc *dsc, void *buf, int size)
130{
131    return dsc->driver->buf_read(dsc->handle, buf, size);
132}
133
134
135int atspi_interrupt(struct atspi_dsc *dsc)
136{
137    return
138        dsc->driver->interrupt ? dsc->driver->interrupt(dsc->handle) : 1;
139}
tools/lib/atspi.c
1/*
2 * lib/atspi.c - ATSPI access functions library
3 *
4 * Written 2010 by Werner Almesberger
5 * Copyright 2010 Werner Almesberger
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13
14#include <stdlib.h>
15#include <stdio.h>
16
17#include "driver.h"
18#include "atspi.h"
19
20
21extern struct atspi_driver atusb_driver;
22extern struct atspi_driver atusd_driver;
23
24
25struct atspi_dsc {
26    struct atspi_driver *driver;
27    void *handle;
28};
29
30
31void *atspi_usb_handle(struct atspi_dsc *dsc)
32{
33#ifdef HAVE_USB
34    return dsc->handle;
35#else
36    return NULL;
37#endif
38}
39
40
41int atspi_error(struct atspi_dsc *dsc)
42{
43    return dsc->driver->error ? dsc->driver->error(dsc->handle) : 0;
44}
45
46
47int atspi_clear_error(struct atspi_dsc *dsc)
48{
49    return dsc->driver->clear_error ?
50        dsc->driver->clear_error(dsc->handle) : 0;
51}
52
53
54struct atspi_dsc *atspi_open(void)
55{
56    struct atspi_dsc *dsc;
57    struct atspi_driver *driver;
58    void *handle;
59
60#ifdef HAVE_USB
61    driver = &atusb_driver;
62#elif HAVE_USD
63    driver = &atusd_driver;
64#else
65#error Need either HAVE_USB or HAVE_USD
66#endif
67    handle = driver->open();
68    if (!handle)
69        return NULL;
70    dsc = malloc(sizeof(*dsc));
71    if (!dsc) {
72        perror("malloc");
73        exit(1);
74    }
75    dsc->driver = driver;
76    dsc->handle = handle;
77    return dsc;
78}
79
80
81void atspi_close(struct atspi_dsc *dsc)
82{
83    if (dsc->driver->close)
84        dsc->driver->close(dsc->handle);
85    free(dsc);
86}
87
88
89void atspi_reset(struct atspi_dsc *dsc)
90{
91    if (dsc->driver->reset)
92        dsc->driver->reset(dsc->handle);
93}
94
95
96void atspi_reset_rf(struct atspi_dsc *dsc)
97{
98    dsc->driver->reset_rf(dsc->handle);
99}
100
101
102int atspi_test_mode(struct atspi_dsc *dsc)
103{
104    if (!dsc->driver->test_mode)
105        return 0;
106    dsc->driver->test_mode(dsc->handle);
107    return 1;
108}
109
110
111void atspi_reg_write(struct atspi_dsc *dsc, uint8_t reg, uint8_t value)
112{
113    dsc->driver->reg_write(dsc->handle, reg, value);
114}
115
116
117uint8_t atspi_reg_read(struct atspi_dsc *dsc, uint8_t reg)
118{
119    return dsc->driver->reg_read(dsc->handle, reg);
120}
121
122
123void atspi_buf_write(struct atspi_dsc *dsc, const void *buf, int size)
124{
125    dsc->driver->buf_write(dsc->handle, buf, size);
126}
127
128
129int atspi_buf_read(struct atspi_dsc *dsc, void *buf, int size)
130{
131    return dsc->driver->buf_read(dsc->handle, buf, size);
132}
133
134
135int atspi_interrupt(struct atspi_dsc *dsc)
136{
137    return
138        dsc->driver->interrupt ? dsc->driver->interrupt(dsc->handle) : 1;
139}

Archive Download the corresponding diff file



interactive