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/] [mcomm_dev.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
#include <linux/kernel.h>
35
#include <linux/module.h>
36
#include <linux/platform_device.h>
37
#include <linux/err.h>
38
#include <linux/ioport.h>
39
 
40
#include "mcomm.h"
41
#include "mcomm_dev.h"
42
 
43
static struct platform_device *mcomm_pdev;
44
 
45
static unsigned long mcomm_base;
46
module_param_named(base, mcomm_base, ulong, 0);
47
MODULE_PARM_DESC(base, "Physical address of the shared memory area");
48
 
49
static unsigned long mcomm_size;
50
module_param_named(size, mcomm_size, ulong, 0);
51
MODULE_PARM_DESC(size, "Size of the shared memory area");
52
 
53
static long mcomm_irq = NO_IRQ;
54
module_param_named(irq, mcomm_irq, long, 0);
55
MODULE_PARM_DESC(irq, "IRQ number used for interprocessor interrupts");
56
 
57
/* Allow user to manually specify the location of a shared memory region.
58
 * Of course, they must also have restricted the kernel's memory usage,
59
 * e.g. with the "mem=" kernel parameter. */
60
int mcomm_pdev_add(void)
61
{
62
        struct resource res[2];
63
        int rc = 0;
64
 
65
        if (!mcomm_size) {
66
                printk(KERN_ERR "%s: please provide base, size, and irq\n", __func__);
67
                return -EINVAL;
68
        }
69
 
70
        memset(res, 0, sizeof(res));
71
 
72
        res[0].start = mcomm_base;
73
        res[0].end = mcomm_base + mcomm_size - 1;
74
        res[0].flags = IORESOURCE_MEM,
75
 
76
        res[1].start = mcomm_irq;
77
        res[1].end = mcomm_irq;
78
        res[1].flags = IORESOURCE_IRQ,
79
 
80
        mcomm_pdev = platform_device_register_simple("mcomm", 0, res, 2);
81
        if (IS_ERR(mcomm_pdev)) {
82
                printk(KERN_WARNING "%s: Failed to create specified shared memory "
83
                        "device.\n", __func__);
84
                return PTR_ERR(mcomm_pdev);
85
        }
86
 
87
        return rc;
88
}
89
EXPORT_SYMBOL(mcomm_pdev_add);
90
 
91
void mcomm_pdev_release(void)
92
{
93
        platform_device_unregister(mcomm_pdev);
94
}
95
EXPORT_SYMBOL(mcomm_pdev_release);
96
 
97
MODULE_LICENSE("GPL v2");
98
MODULE_AUTHOR("Hollis Blanchard <hollis_blanchard@mentor.com>");
99
MODULE_DESCRIPTION("Manually specify shared memory area");

powered by: WebSVN 2.1.0

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