source: mainline/uspace/lib/c/include/device/hw_res_parsed.h@ 75701004

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 75701004 was a35b458, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 7 years ago

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2 * Copyright (c) 2011 Jiri Michalec
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
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup libc
30 * @{
31 */
32/** @file
33 */
34
35#ifndef LIBC_DEVICE_HW_RES_PARSED_H_
36#define LIBC_DEVICE_HW_RES_PARSED_H_
37
38#include <device/hw_res.h>
39#include <device/pio_window.h>
40#include <str.h>
41
42/** Keep areas of the zero size in the list */
43#define HW_RES_KEEP_ZERO_AREA 0x1
44
45/** Keep duplicit entries */
46#define HW_RES_KEEP_DUPLICIT 0x2
47
48
49#define RNGABS(rng) (rng).address.absolute
50#define RNGREL(rng) (rng).address.relative
51#define RNGSZ(rng) (rng).size
52
53#define RNGABSPTR(rng) ((void *) ((uintptr_t) RNGABS((rng))))
54
55typedef struct address64 {
56 /** Aboslute address. */
57 uint64_t absolute;
58 /** PIO window base relative address. */
59 uint64_t relative;
60} address64_t;
61
62/** Address range structure */
63typedef struct addr_range {
64 /** Start address */
65 address64_t address;
66
67 /** Area size */
68 size_t size;
69
70 /** Endianness */
71 endianness_t endianness;
72} addr_range_t;
73
74/** IO range type */
75typedef addr_range_t io_range_t;
76
77/** Memory range type */
78typedef addr_range_t mem_range_t;
79
80/** List of IRQs */
81typedef struct irq_list {
82 /** Irq count */
83 size_t count;
84
85 /** Array of IRQs */
86 int *irqs;
87} irq_list_t;
88
89/** List of ISA DMA channels */
90typedef struct dma_list {
91 /** Channel count */
92 size_t count;
93
94 /** Array of channels */
95 unsigned int *channels;
96} dma_list_t;
97
98/** List of memory areas */
99typedef struct addr_range_list {
100 /** Areas count */
101 size_t count;
102
103 /** Array of areas */
104 addr_range_t *ranges;
105} addr_range_list_t;
106
107/** List of IO mapped areas */
108typedef addr_range_list_t io_range_list_t;
109
110/** Memory range type */
111typedef addr_range_list_t mem_range_list_t;
112
113/** HW resources parsed according to resource type */
114typedef struct hw_resource_list_parsed {
115 /** List of IRQs */
116 irq_list_t irqs;
117
118 /** List of DMA channels */
119 dma_list_t dma_channels;
120
121 /** List of memory areas */
122 mem_range_list_t mem_ranges;
123
124 /** List of IO areas */
125 io_range_list_t io_ranges;
126} hw_res_list_parsed_t;
127
128/** Clean hw_resource_list_parsed_t structure
129 *
130 * All allocated memory will be released, data amd pointers set to 0.
131 *
132 * @param list The structure to clear
133 */
134static inline void hw_res_list_parsed_clean(hw_res_list_parsed_t *list)
135{
136 if (list == NULL)
137 return;
138
139 free(list->irqs.irqs);
140 free(list->io_ranges.ranges);
141 free(list->mem_ranges.ranges);
142 free(list->dma_channels.channels);
143
144 memset(list, 0, sizeof(hw_res_list_parsed_t));
145}
146
147/** Initialize the hw_resource_list_parsed_t structure
148 *
149 * @param list The structure to initialize
150 */
151static inline void hw_res_list_parsed_init(hw_res_list_parsed_t *list)
152{
153 memset(list, 0, sizeof(hw_res_list_parsed_t));
154}
155
156extern errno_t hw_res_list_parse(const pio_window_t *, const hw_resource_list_t *,
157 hw_res_list_parsed_t *, int);
158extern errno_t hw_res_get_list_parsed(async_sess_t *, hw_res_list_parsed_t *, int);
159
160#endif
161
162/** @}
163 */
Note: See TracBrowser for help on using the repository browser.