fd847f1e08b56d56d42047f46bfa242f761f05a2
2 /*
3 * Copyright (c) 2014, Mentor Graphics Corporation
4 * All rights reserved.
5 *
6 * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32 #include <string.h>
33 #include "xparameters.h"
34 #include "xil_exception.h"
35 #include "xscugic.h"
36 #include "metal/sys.h"
37 #include "metal/device.h"
38 #include "metal/io.h"
39 #include "metal/shmem.h"
41 /** Device base address */
42 #define IPI_BASE_ADDR 0xFF310000
43 #define UNDEFINE_BASE_ADDR 0x0
45 #define UNDEFINE_MEM_SIZE 0xFFFFFFFF
47 /** IPI IRQ ID */
48 #define IPI_IRQ_VECT_ID 65
50 #define IPI_DEV_NAME "ff310000.ipi"
51 #define VRING_DEV_NAME "vrings"
52 #define SHM_NAME "shm"
54 const metal_phys_addr_t ipi_base_addr = IPI_BASE_ADDR;
55 const metal_phys_addr_t undefine_mem_addr = UNDEFINE_BASE_ADDR;
57 struct metal_device metal_dev_table[] = {
58 {
59 /* IPI device */
60 IPI_DEV_NAME,
61 NULL,
62 1,
63 {
64 {
65 (void *)IPI_BASE_ADDR,
66 &ipi_base_addr,
67 0x1000,
68 (sizeof(metal_phys_addr_t) << 3),
69 (unsigned long)(-1),
70 METAL_UNCACHED,
71 {NULL},
72 }
73 },
74 {NULL},
75 1,
76 (void *)IPI_IRQ_VECT_ID,
78 },
79 {
80 /* Shared memory management device */
81 VRING_DEV_NAME,
82 NULL,
83 1,
84 {
85 {
86 (void *)UNDEFINE_BASE_ADDR,
87 &undefine_mem_addr,
88 UNDEFINE_MEM_SIZE,
89 (sizeof(metal_phys_addr_t) << 3),
90 (unsigned long)(-1),
91 METAL_UNCACHED | METAL_SHARED_MEM,
92 {NULL},
93 }
94 },
95 {NULL},
96 0,
97 NULL,
99 },
100 };
102 struct metal_generic_shmem shm = {
103 SHM_NAME,
104 {
105 (void *)UNDEFINE_BASE_ADDR,
106 &undefine_mem_addr,
107 UNDEFINE_MEM_SIZE,
108 (sizeof(metal_phys_addr_t) << 3),
109 (unsigned long)(-1),
110 0,
111 {NULL},
112 },
113 {NULL, NULL},
114 };
116 /**
117 * This funciton is to install baremeta/RTOS libmetal devices.
118 */
119 extern char RPROC_DEBUG[];
120 int platform_register_metal_device(void)
121 {
122 int i;
123 int ret;
124 struct metal_device *dev;
126 /* Register device */
127 metal_bus_register(&metal_generic_bus);
128 for (i = 0;
129 i < (int)(sizeof(metal_dev_table)/sizeof(struct metal_device));
130 i++) {
131 dev = &metal_dev_table[i];
132 ret = metal_register_generic_device(dev);
133 if (ret)
134 return ret;
135 }
137 /* Register shared memory */
138 metal_shmem_register_generic(&shm);
140 return 0;
141 }