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

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.swp.api/] [openmcapi/] [1.0/] [libmcapi/] [shm/] [linux/] [kmod/] [loop.c] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
/*
2
 * Copyright (c) 2010, Mentor Graphics Corporation
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 *
8
 * 1. Redistributions of source code must retain the above copyright notice,
9
 *    this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
11
 *    this list of conditions and the following disclaimer in the documentation
12
 *    and/or other materials provided with the distribution.
13
 * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
14
 *    may be used to endorse or promote products derived from this software
15
 *    without specific prior written permission.
16
 *
17
 * Alternatively, this software may be distributed under the terms of the
18
 * GNU General Public License ("GPL") version 2 as published by the Free
19
 * Software Foundation.
20
 *
21
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
 * POSSIBILITY OF SUCH DAMAGE.
32
 */
33
 
34
/*
35
 * This file exists only to provide a driver for testing userspace code on
36
 * single-core platforms.
37
 *
38
 * The interrupt functions won't even be called. Instead of calling
39
 * ops->notify() for the single core, the higher level code directly calls its
40
 * interrupt handler instead.
41
 */
42
 
43
#include <linux/kernel.h>
44
#include <linux/mm.h>
45
#include <linux/io.h>
46
#include <linux/module.h>
47
#include <linux/platform_device.h>
48
 
49
#include "mcomm.h"
50
#include "mcomm_dev.h"
51
 
52
static pgprot_t mcomm_loop_mmap_pgprot(struct vm_area_struct *vma)
53
{
54
        return vma->vm_page_prot;
55
}
56
 
57
static void __iomem *mcomm_loop_ioremap(unsigned long phys_addr, size_t size)
58
{
59
#if defined(CONFIG_ARM)
60
        return ioremap_cached(phys_addr, size);
61
#elif defined(CONFIG_X86)
62
        return ioremap_cache(phys_addr, size);
63
#endif
64
        return ioremap(phys_addr, size);
65
}
66
 
67
static void mcomm_loop_notify(u32 core_nr)
68
{
69
        BUG();
70
}
71
 
72
static void mcomm_loop_ack(void)
73
{
74
        BUG();
75
}
76
 
77
static unsigned long mcomm_loop_cpuid(void)
78
{
79
        return 0;
80
}
81
 
82
static struct mcomm_platform_ops mcomm_loop_ops = {
83
        .mmap_pgprot = mcomm_loop_mmap_pgprot,
84
        .map = mcomm_loop_ioremap,
85
        .notify = mcomm_loop_notify,
86
        .ack = mcomm_loop_ack,
87
        .cpuid = mcomm_loop_cpuid,
88
};
89
 
90
 
91
static int __devinit mcomm_probe(struct platform_device *pdev)
92
{
93
        struct resource *mem;
94
        struct resource *irq;
95
 
96
        mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
97
        if (!mem)
98
                return -EINVAL;
99
 
100
        irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
101
        if (!irq)
102
                return -EINVAL;
103
 
104
        return mcomm_new_region(&pdev->dev, mem, irq);
105
}
106
 
107
static int mcomm_remove(struct platform_device *pdev)
108
{
109
        mcomm_remove_region(&pdev->dev);
110
 
111
        return 0;
112
}
113
 
114
static struct platform_driver mcomm_driver = {
115
        .probe = mcomm_probe,
116
        .remove = mcomm_remove,
117
        .driver = {
118
                   .name = "mcomm",
119
        }
120
};
121
 
122
static int __init mcomm_loop_modinit(void)
123
{
124
        int rc;
125
 
126
        rc = mcomm_init(&mcomm_loop_ops, THIS_MODULE);
127
        if (rc) {
128
                printk(KERN_ERR "%s: Failed to initialize mcomm driver.\n", __func__);
129
                goto out1;
130
        }
131
 
132
        rc = platform_driver_register(&mcomm_driver);
133
        if (rc) {
134
                printk(KERN_ERR "%s: Failed to register platform driver.\n", __func__);
135
                goto out2;
136
        }
137
 
138
        /* Finally, register an mcomm device. We can only have one, so if there's
139
         * an error we should just give up. */
140
        rc = mcomm_pdev_add();
141
        if (rc)
142
                goto out2;
143
 
144
        return 0;
145
 
146
out2:
147
        mcomm_exit();
148
out1:
149
        return rc;
150
}
151
module_init(mcomm_loop_modinit);
152
 
153
static void mcomm_loop_modexit(void)
154
{
155
        mcomm_pdev_release();
156
        platform_driver_unregister(&mcomm_driver);
157
        mcomm_exit();
158
}
159
module_exit(mcomm_loop_modexit);
160
 
161
MODULE_LICENSE("GPL v2");
162
MODULE_AUTHOR("Hollis Blanchard <hollis_blanchard@mentor.com>");
163
MODULE_DESCRIPTION("Loopback driver for testing multi-core communications driver");

powered by: WebSVN 2.1.0

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