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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since c891eaca was 00d7e1b, checked in by Martin Decky <martin@…>, 14 years ago

networking improvements

  • start the networking stack from init
  • add loopback network interface driver (cherrypicked and sanitized from lp:~helenos-nicf/helenos/nicf)
  • add libnic and various small pieces from lp:~helenos-nicf/helenos/nicf
  • fix client side of NIC_GET_ADDRESS
  • net binary overhaul

Note: "ping 127.0.0.1" works, but the first three pings timeout for some reason

  • Property mode set to 100644
File size: 3.5 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 memory areas */
75typedef struct addr_range_list {
76 /** Areas count */
77 size_t count;
78
79 /** Array of areas */
80 addr_range_t *ranges;
81} addr_range_list_t;
82
83/** List of IO mapped areas */
84typedef addr_range_list_t io_range_list_t;
85
86/** Memory range type */
87typedef addr_range_list_t mem_range_list_t;
88
89/** HW resources parsed according to resource type */
90typedef struct hw_resource_list_parsed {
91 /** List of IRQs */
92 irq_list_t irqs;
93
94 /** List of memory areas */
95 mem_range_list_t mem_ranges;
96
97 /** List of IO areas */
98 io_range_list_t io_ranges;
99} hw_res_list_parsed_t;
100
101/** Clean hw_resource_list_parsed_t structure
102 *
103 * All allocated memory will be released, data amd pointers set to 0.
104 *
105 * @param list The structure to clear
106 */
107static inline void hw_res_list_parsed_clean(hw_res_list_parsed_t *list)
108{
109 if (list == NULL)
110 return;
111
112 free(list->irqs.irqs);
113 free(list->io_ranges.ranges);
114 free(list->mem_ranges.ranges);
115
116 bzero(list, sizeof(hw_res_list_parsed_t));
117}
118
119/** Initialize the hw_resource_list_parsed_t structure
120 *
121 * @param list The structure to initialize
122 */
123static inline void hw_res_list_parsed_init(hw_res_list_parsed_t *list)
124{
125 bzero(list, sizeof(hw_res_list_parsed_t));
126}
127
128extern int hw_res_list_parse(hw_resource_list_t *, hw_res_list_parsed_t *, int);
129extern int hw_res_get_list_parsed(async_sess_t *, hw_res_list_parsed_t *, int);
130
131#endif
132
133/** @}
134 */
Note: See TracBrowser for help on using the repository browser.