5 * (c) 2008-2010 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
6 * Alexander Warg <warg@os.inf.tu-dresden.de>
7 * economic rights: Technische Universität Dresden (Germany)
8 * This file is part of TUD:OS and distributed under the terms of the
9 * GNU Lesser General Public License 2.1.
10 * Please see the COPYING-LGPL-2.1 file for details.
16 #include <l4/sys/types.h>
17 #include <l4/sys/linkage.h>
18 #include <l4/io/types.h>
23 * \defgroup api_l4io IO interface
28 * \brief Request an interrupt.
31 * \param irqnum IRQ number.
32 * \param irqcap Capability index to attach the IRQ to.
33 * \return 0 on success, <0 on error
35 * \note This function is internal because libirq is handling IRQs. This
36 * is rather the interface to get the IRQ.
39 l4io_request_irq(int irqnum, l4_cap_idx_t irqcap);
42 * \brief Request the ICU object of the client.
44 * \return Client ICU object, an invalid capability selector is returned if
45 * no ICU is available.
47 L4_CV l4_cap_idx_t L4_EXPORT
48 l4io_request_icu(void);
52 * \brief Release an interrupt.
55 * \param irqnum IRQ number.
56 * \return 0 on success, <0 on error
58 * \note This function is internal because libirq is handling IRQs. This
59 * is rather the interface to return the IRQ.
62 l4io_release_irq(int irqnum, l4_cap_idx_t irq_cap);
65 * \brief Request an IO memory region.
67 * \param phys Physical address of the I/O memory region
68 * \param size Size of the region in Bytes, granularity pages.
69 * \param flags See #l4io_iomem_flags_t
70 * \retval virt Virtual address the region is available at.
71 * \return 0 on success, <0 on error
73 * \note This function uses L4Re functionality to reserve a part of the
74 * virtual address space of the caller.
77 l4io_request_iomem(l4_addr_t phys, unsigned long size, int flags,
81 * \brief Request an IO memory region and map to a specified region.
83 * \param phys Physical address of the I/O memory region
84 * \param virt Virtual address.
85 * \param size Size of the region in Bytes, granularity pages.
86 * \param flags See #l4io_iomem_flags_t
87 * \return 0 on success, <0 on error
89 * \note This function uses L4Re functionality to reserve a part of the
90 * virtual address space of the caller.
93 l4io_request_iomem_region(l4_addr_t phys, l4_addr_t virt,
94 unsigned long size, int flags);
97 * \brief Release an IO memory region.
99 * \param virt Virtual address of region to free, see #l4io_request_iomem
100 * \param size Size of the region to release.
101 * \return 0 on success, <0 on error
104 l4io_release_iomem(l4_addr_t virt, unsigned long size);
107 * \brief Search for a IO memory region.
109 * \param phys Physical address to look for
110 * \param size Size of requested memory area
111 * \retval rstart Start address for region
112 * \retval rsize Size of region in bytes
113 * \return 0 if an IO region was found, <0 if not
116 l4io_search_iomem_region(l4_addr_t phys, l4_addr_t size,
117 l4_addr_t *rstart, l4_addr_t *rsize);
120 * \brief Request an IO port region.
122 * \param portnum Start of port range to request
123 * \param len Length of range to request
124 * \return 0 on success, <0 on error
126 * \note X86 architecture only
129 l4io_request_ioport(unsigned portnum, unsigned len);
132 * \brief Release an IO port region.
134 * \param portnum Start of port range to release
135 * \param len Length of range to request
136 * \return 0 on success, <0 on error
138 * \note X86 architecture only
141 l4io_release_ioport(unsigned portnum, unsigned len);
147 /* -------------- Device handling --------------------- */
150 * \brief Get root device handle of the device bus.
152 * \return root device handle
155 l4io_device_handle_t l4io_get_root_device(void);
158 * \brief Iterate over the device bus.
160 * \param devhandle Device handle to start iterating at
161 * \retval devhandle Next device handle
162 * \retval dev Device information, may be NULL
163 * \retval reshandle Resource handle.
164 * \return 0 on success, error code otherwise
167 l4io_iterate_devices(l4io_device_handle_t *devhandle,
168 l4io_device_t *dev, l4io_resource_handle_t *reshandle);
171 * \brief Find a device by name.
174 * \param devname Name of device
175 * \retval dev_handle Device handle for found device, can be NULL.
176 * \retval dev Device information, filled by the function, can be NULL.
177 * \retval res_handle Resource handle, can be NULL.
179 * \return 0 on success, error code otherwise
182 l4io_lookup_device(const char *devname,
183 l4io_device_handle_t *dev_handle,
184 l4io_device_t *dev, l4io_resource_handle_t *res_handle);
187 * \brief Request a specific resource from a device description.
190 * \param devhandle Device handle.
191 * \param type Type of resource to request (see \#l4io_resource_types_t)
192 * \param reshandle Resource handle,
193 * start with handle returned by device functions.
194 * \retval reshandle Next resource handle.
195 * \retval res Device descriptor
197 * \return 0 on success, error code otherwise, esp. -L4_ENOENT if no more
201 l4io_lookup_resource(l4io_device_handle_t devhandle,
202 enum l4io_resource_types_t type,
203 l4io_resource_handle_t *reshandle,
204 l4io_resource_t *res);
207 /* --------------- Convenience functions ----------------- */
210 * \brief Request IO memory.
213 * \param devhandle Device handle.
214 * \retval reshandle Resource handle, input and ouput, return next resource
217 * \return 0 on error, virtual address otherwise
219 L4_CV l4_addr_t L4_EXPORT
220 l4io_request_resource_iomem(l4io_device_handle_t devhandle,
221 l4io_resource_handle_t *reshandle);
224 * \brief Request all available IO-port resources.
227 l4io_request_all_ioports(void);
231 l4io_device_handle_t l4io_get_root_device(void)