source: rtems-libbsd/rtemsbsd/include/rtems/bsd/bsd.h @ ea395a7

55-freebsd-126-freebsd-12
Last change on this file since ea395a7 was ea395a7, checked in by Kevin Kirspel <kevin-kirspel@…>, on 01/30/17 at 16:58:18

Add ordered Nexus devices

Add support for ordering the initialization of Nexus devices. This can
be used to make sure a device is initialized before a dependant device.

  • Property mode set to 100755
File size: 7.5 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup rtems_bsd
5 *
6 * @brief TODO.
7 */
8
9/*
10 * Copyright (c) 2009, 2016 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Dornierstr. 4
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 * 1. Redistributions of source code must retain the above copyright
22 *    notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 *    notice, this list of conditions and the following disclaimer in the
25 *    documentation and/or other materials provided with the distribution.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 */
39
40#ifndef _RTEMS_BSD_BSD_H_
41#define _RTEMS_BSD_BSD_H_
42
43#include <sys/cdefs.h>
44#include <sys/queue.h>
45#include <sys/kernel.h>
46
47#include <stdarg.h>
48
49#include <rtems.h>
50
51#ifdef __cplusplus
52extern "C" {
53#endif /* __cplusplus */
54
55/*
56 * The default memory size. Do not change, use
57 * RTEMS_BSD_CONFIG_DOMAIN_PAGE_MBUFS_SIZE to override for your application.
58 */
59#define RTEMS_BSD_ALLOCATOR_DOMAIN_PAGE_MBUF_DEFAULT (8 * 1024 * 1024)
60
61typedef enum {
62        RTEMS_BSD_RES_IRQ = 1,
63        RTEMS_BSD_RES_MEMORY = 3
64} rtems_bsd_device_resource_type;
65
66typedef struct {
67        rtems_bsd_device_resource_type type;
68        unsigned long start_request;
69        unsigned long start_actual;
70} rtems_bsd_device_resource;
71
72typedef struct {
73        const char *name;
74        int unit;
75        size_t resource_count;
76        const rtems_bsd_device_resource *resources;
77        const struct sysinit *driver_reference;
78} rtems_bsd_device;
79
80#define RTEMS_BSD_DEFINE_NEXUS_DEVICE(name, unit, resource_count, resources) \
81    extern struct sysinit SYSINIT_ENTRY_NAME(name##_nexusmodule); \
82    RTEMS_BSD_DEFINE_SET_ITEM(nexus, name##unit, rtems_bsd_device) = \
83        { #name, unit, (resource_count), (resources), \
84            &SYSINIT_ENTRY_NAME(name##_nexusmodule) }
85
86#define RTEMS_BSD_DEFINE_NEXUS_DEVICE_ORDERED(name, unit, order, resource_count, resources) \
87    extern struct sysinit SYSINIT_ENTRY_NAME(name##_nexusmodule); \
88    RTEMS_BSD_DEFINE_SET_ITEM_ORDERED(nexus, name##unit, order, rtems_bsd_device) = \
89        { #name, unit, (resource_count), (resources), \
90            &SYSINIT_ENTRY_NAME(name##_nexusmodule) }
91
92rtems_status_code rtems_bsd_initialize(void);
93
94/**
95 * @brief Returns the initial priority for a task specified by its name.
96 *
97 * Applications may provide their own implementation of this function.  For
98 * example they can define their implementation in the same module which calls
99 * rtems_bsd_initialize().
100 *
101 * @param[in] name The task name.
102 *
103 * @return The desired initial task priority.
104 */
105rtems_task_priority rtems_bsd_get_task_priority(const char *name);
106
107/**
108 * @brief Returns the stack size for a task specified by its name.
109 *
110 * Applications may provide their own implementation of this function.  For
111 * example they can define their implementation in the same module which calls
112 * rtems_bsd_initialize().
113 *
114 * @param[in] name The task name.
115 *
116 * @return The desired task stack size.
117 */
118size_t rtems_bsd_get_task_stack_size(const char *name);
119
120typedef enum {
121        RTEMS_BSD_ALLOCATOR_DOMAIN_PAGE,
122        RTEMS_BSD_ALLOCATOR_DOMAIN_MBUF,
123        RTEMS_BSD_ALLOCATOR_DOMAIN_MALLOC
124} rtems_bsd_allocator_domain;
125
126/**
127 * @brief The size for the page/mbufs default allocator domain.
128 *
129 * Applications may set this value to change the value returned by the default.
130 */
131extern uintptr_t rtems_bsd_allocator_domain_page_mbuf_size;
132
133/**
134 * @brief Returns the size for a specific allocator domain.
135 *
136 * Applications may provide their own implementation of this function.  For
137 * example they can define their implementation in the same module which calls
138 * rtems_bsd_initialize().
139 *
140 * @param[in] domain The allocator domain.
141 *
142 * @return The desired size for the specified allocator domain.
143 */
144uintptr_t rtems_bsd_get_allocator_domain_size(
145    rtems_bsd_allocator_domain domain);
146
147/**
148 * @brief Returns the Ethernet MAC address for a specified device.
149 *
150 * Applications may provide their own implementation of this function.  For
151 * example they can define their implementation in the same module which calls
152 * rtems_bsd_initialize().
153 *
154 * The default implementation returns
155 * { 0x0e, 0xb0, 0xba, 0x5e, 0xba, 0x11 + unit }.
156 *
157 * This is a workaround.  A better approach would be to use a device tree and a
158 * bus device similar to the FreeBSD SIMPLEBUS(4).
159 *
160 * @param[in] name The device name.
161 * @param[in] unit The device unit.
162 * @param[out] mac_addr The Ethernet MAC address.
163 */
164void rtems_bsd_get_mac_address(const char *name, int unit,
165    uint8_t mac_addr[6]);
166
167/**
168 * @defgroup BSDBusRoot Bus Root Functions
169 *
170 * @brief Functions to perform bus root operations.
171 *
172 * Suspend and resume can be used to go into or exit a power saving state.
173 * Detach may be used to shutdown the system and do a warm reset.
174 *
175 * All functions must be called from task context.  They perform complex
176 * operations affecting all devices of the bus tree and work only if all
177 * drivers are written properly and no resources used by the drivers are
178 * blocked.
179 *
180 * @{
181 */
182
183/**
184 * @brief Attach the root bus.
185 *
186 * @retval 0 Successful operation.
187 * @retval errno Otherwise.
188 */
189int rtems_bsd_bus_root_attach(void);
190
191/**
192 * @brief Suspend the root bus.
193 *
194 * @retval 0 Successful operation.
195 * @retval errno Otherwise.
196 */
197int rtems_bsd_bus_root_suspend(void);
198
199/**
200 * @brief Resume the root bus.
201 *
202 * @retval 0 Successful operation.
203 * @retval errno Otherwise.
204 */
205int rtems_bsd_bus_root_resume(void);
206
207/**
208 * @brief Detach the root bus.
209 *
210 * @retval 0 Successful operation.
211 * @retval errno Otherwise.
212 */
213int rtems_bsd_bus_root_detach(void);
214
215/**
216 * @brief The output back-end for logging functions.
217 */
218typedef int (*rtems_bsd_vprintf_handler)(int, const char *, va_list);
219
220/**
221 * @brief Sets the output back-end for logging functions.
222 *
223 * @param new_handler The new output back-end for logging functions.
224 *
225 * @return The previous handler.
226 *
227 * @see rtems_bsd_vprintf().
228 */
229rtems_bsd_vprintf_handler rtems_bsd_set_vprintf_handler(
230    rtems_bsd_vprintf_handler new_handler);
231
232/**
233 * @brief Output back-end for logging functions.
234 *
235 * Used by kernel space printf(), vprintf(), log() and vlog().  Used by user
236 * space syslog() and vsyslog().
237 *
238 * The default uses putchar() and uses a mutex to serialize the output.  It may
239 * be customized via rtems_bsd_set_vprintf_handler().
240 */
241int rtems_bsd_vprintf(int level, const char *fmt, va_list ap);
242
243/**
244 * @brief Set the syslog priority. See syslog.h for the names.
245 *
246 * @param priority One of the standard names.
247 * @retval 0 Priority set.
248 * @retval errno Otherwise.
249 */
250int rtems_bsd_setlogpriority(const char* priority);
251
252/** @} */
253
254#ifdef __cplusplus
255}
256#endif /* __cplusplus */
257
258#endif /* _RTEMS_BSD_BSD_H_ */
Note: See TracBrowser for help on using the repository browser.