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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 6843a9c was 6843a9c, checked in by Jan Vesely <jano.vesely@…>, 13 years ago

Merge mainline changes

Trivial conflicts.

  • Property mode set to 100644
File size: 3.9 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 <str.h>
40
41/** Keep areas of the zero size in the list */
42#define HW_RES_KEEP_ZERO_AREA 0x1
43
44/** Keep duplicit entries */
45#define HW_RES_KEEP_DUPLICIT 0x2
46
47/** Address range structure */
48typedef struct addr_range {
49 /** Start address */
50 uint64_t address;
51
52 /** Endianness */
53 endianness_t endianness;
54
55 /** Area size */
56 size_t size;
57} addr_range_t;
58
59/** IO range type */
60typedef addr_range_t io_range_t;
61
62/** Memory range type */
63typedef addr_range_t mem_range_t;
64
65/** List of IRQs */
66typedef struct irq_list {
67 /** Irq count */
68 size_t count;
69
70 /** Array of IRQs */
71 int *irqs;
72} irq_list_t;
73
74/** List of ISA DMA channels */
75typedef struct dma_list {
76 /** Channel count */
77 size_t count;
78
79 /** Array of channels */
80 unsigned int *channels;
81} dma_list_t;
82
83/** List of memory areas */
84typedef struct addr_range_list {
85 /** Areas count */
86 size_t count;
87
88 /** Array of areas */
89 addr_range_t *ranges;
90} addr_range_list_t;
91
92/** List of IO mapped areas */
93typedef addr_range_list_t io_range_list_t;
94
95/** Memory range type */
96typedef addr_range_list_t mem_range_list_t;
97
98/** HW resources parsed according to resource type */
99typedef struct hw_resource_list_parsed {
100 /** List of IRQs */
101 irq_list_t irqs;
102
103 /** List of DMA channels */
104 dma_list_t dma_channels;
105
106 /** List of DMA channels */
107 dma_list_t dma_channels;
108
109 /** List of memory areas */
110 mem_range_list_t mem_ranges;
111
112 /** List of IO areas */
113 io_range_list_t io_ranges;
114} hw_res_list_parsed_t;
115
116/** Clean hw_resource_list_parsed_t structure
117 *
118 * All allocated memory will be released, data amd pointers set to 0.
119 *
120 * @param list The structure to clear
121 */
122static inline void hw_res_list_parsed_clean(hw_res_list_parsed_t *list)
123{
124 if (list == NULL)
125 return;
126
127 free(list->irqs.irqs);
128 free(list->io_ranges.ranges);
129 free(list->mem_ranges.ranges);
130 free(list->dma_channels.channels);
131
132 bzero(list, sizeof(hw_res_list_parsed_t));
133}
134
135/** Initialize the hw_resource_list_parsed_t structure
136 *
137 * @param list The structure to initialize
138 */
139static inline void hw_res_list_parsed_init(hw_res_list_parsed_t *list)
140{
141 bzero(list, sizeof(hw_res_list_parsed_t));
142}
143
144extern int hw_res_list_parse(
145 const hw_resource_list_t *, hw_res_list_parsed_t *, int);
146extern int hw_res_get_list_parsed(async_sess_t *, hw_res_list_parsed_t *, int);
147
148#endif
149
150/** @}
151 */
Note: See TracBrowser for help on using the repository browser.