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

55-freebsd-126-freebsd-12freebsd-9.3
Last change on this file since f01b1f72 was f01b1f72, checked in by Chris Johns <chrisj@…>, on 06/30/16 at 01:42:49

Add RTEMS_BSD_CONFIG_DOMAIN_PAGE_MBUFS_SIZE.

The domain allocator page abd mbuf size can be configured by the
user using RTEMS_BSD_CONFIG_DOMAIN_PAGE_MBUFS_SIZE.

  • Property mode set to 100644
File size: 7.0 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
86rtems_status_code rtems_bsd_initialize(void);
87
88/**
89 * @brief Returns the initial priority for a task specified by its name.
90 *
91 * Applications may provide their own implementation of this function.  For
92 * example they can define their implementation in the same module which calls
93 * rtems_bsd_initialize().
94 *
95 * @param[in] name The task name.
96 *
97 * @return The desired initial task priority.
98 */
99rtems_task_priority rtems_bsd_get_task_priority(const char *name);
100
101/**
102 * @brief Returns the stack size for a task specified by its name.
103 *
104 * Applications may provide their own implementation of this function.  For
105 * example they can define their implementation in the same module which calls
106 * rtems_bsd_initialize().
107 *
108 * @param[in] name The task name.
109 *
110 * @return The desired task stack size.
111 */
112size_t rtems_bsd_get_task_stack_size(const char *name);
113
114typedef enum {
115        RTEMS_BSD_ALLOCATOR_DOMAIN_PAGE,
116        RTEMS_BSD_ALLOCATOR_DOMAIN_MBUF,
117        RTEMS_BSD_ALLOCATOR_DOMAIN_MALLOC
118} rtems_bsd_allocator_domain;
119
120/**
121 * @brief The size for the page/mbufs default allocator domain.
122 *
123 * Applications may set this value to change the value returned by the default.
124 */
125extern uintptr_t rtems_bsd_allocator_domain_page_mbuf_size;
126
127/**
128 * @brief Returns the size for a specific allocator domain.
129 *
130 * Applications may provide their own implementation of this function.  For
131 * example they can define their implementation in the same module which calls
132 * rtems_bsd_initialize().
133 *
134 * @param[in] domain The allocator domain.
135 *
136 * @return The desired size for the specified allocator domain.
137 */
138uintptr_t rtems_bsd_get_allocator_domain_size(
139    rtems_bsd_allocator_domain domain);
140
141/**
142 * @brief Returns the Ethernet MAC address for a specified device.
143 *
144 * Applications may provide their own implementation of this function.  For
145 * example they can define their implementation in the same module which calls
146 * rtems_bsd_initialize().
147 *
148 * The default implementation returns
149 * { 0x0e, 0xb0, 0xba, 0x5e, 0xba, 0x11 + unit }.
150 *
151 * This is a workaround.  A better approach would be to use a device tree and a
152 * bus device similar to the FreeBSD SIMPLEBUS(4).
153 *
154 * @param[in] name The device name.
155 * @param[in] unit The device unit.
156 * @param[out] mac_addr The Ethernet MAC address.
157 */
158void rtems_bsd_get_mac_address(const char *name, int unit,
159    uint8_t mac_addr[6]);
160
161/**
162 * @defgroup BSDBusRoot Bus Root Functions
163 *
164 * @brief Functions to perform bus root operations.
165 *
166 * Suspend and resume can be used to go into or exit a power saving state.
167 * Detach may be used to shutdown the system and do a warm reset.
168 *
169 * All functions must be called from task context.  They perform complex
170 * operations affecting all devices of the bus tree and work only if all
171 * drivers are written properly and no resources used by the drivers are
172 * blocked.
173 *
174 * @{
175 */
176
177/**
178 * @brief Attach the root bus.
179 *
180 * @retval 0 Successful operation.
181 * @retval errno Otherwise.
182 */
183int rtems_bsd_bus_root_attach(void);
184
185/**
186 * @brief Suspend the root bus.
187 *
188 * @retval 0 Successful operation.
189 * @retval errno Otherwise.
190 */
191int rtems_bsd_bus_root_suspend(void);
192
193/**
194 * @brief Resume the root bus.
195 *
196 * @retval 0 Successful operation.
197 * @retval errno Otherwise.
198 */
199int rtems_bsd_bus_root_resume(void);
200
201/**
202 * @brief Detach the root bus.
203 *
204 * @retval 0 Successful operation.
205 * @retval errno Otherwise.
206 */
207int rtems_bsd_bus_root_detach(void);
208
209/**
210 * @brief Sets the output back-end for logging functions.
211 *
212 * @param new_vprintf_handler The new output back-end for logging functions.
213 *
214 * @see rtems_bsd_vprintf().
215 */
216void rtems_bsd_set_vprintf_handler(int (*new_vprintf_handler)
217    (int, const char *, va_list));
218
219/**
220 * @brief Output back-end for logging functions.
221 *
222 * Used by kernel space printf(), vprintf(), log() and vlog().  Used by user
223 * space syslog() and vsyslog().
224 *
225 * The default uses putchar() and uses a mutex to serialize the output.  It may
226 * be customized via rtems_bsd_set_vprintf_handler().
227 */
228int rtems_bsd_vprintf(int level, const char *fmt, va_list ap);
229
230/**
231 * @brief Set the syslog priority. See syslog.h for the names.
232 *
233 * @param priority One of the standard names.
234 * @retval 0 Priority set.
235 * @retval errno Otherwise.
236 */
237int rtems_bsd_setlogpriority(const char* priority);
238
239/** @} */
240
241#ifdef __cplusplus
242}
243#endif /* __cplusplus */
244
245#endif /* _RTEMS_BSD_BSD_H_ */
Note: See TracBrowser for help on using the repository browser.