vbus() = L4Re::Env::env()->get_cap<void>("vbus");
if (!vbus().is_valid())
{
- printf("libio: Warning: Query of 'vbus' failed with!\n");
+ printf("libio: Warning: Query of 'vbus' failed!\n");
return;
}
__map_iomem(l4_addr_t phys, l4_addr_t* virt, unsigned long size, int flags)
{
Cap<L4Re::Dataspace> iomem = L4::cap_cast<L4Re::Dataspace>(vbus());
+ unsigned char align = L4_PAGESHIFT;
- int res = L4Re::Env::env()->rm()->attach(virt, size,
- *virt
- ? (flags & L4IO_MEM_USE_RESERVED_AREA ? L4Re::Rm::In_area : 0)
- : L4Re::Rm::Search_addr, iomem, phys);
+ if (size >= L4_SUPERPAGESIZE)
+ align = L4_SUPERPAGESHIFT;
+
+ unsigned long rmflags = 0;
+
+ if (flags & L4IO_MEM_EAGER_MAP)
+ rmflags |= L4Re::Rm::Eager_map;
+
+ if (*virt && (flags & L4IO_MEM_USE_RESERVED_AREA))
+ rmflags |= L4Re::Rm::In_area;
+
+ if (!*virt)
+ rmflags |= L4Re::Rm::Search_addr;
+
+ int res = L4Re::Env::env()->rm()->attach(virt, size, rmflags, iomem, phys, align);
if (res)
{
printf("Cannot attach iomem to virtual address %lx with size %lx: %s(%d).\n",
{
__l4io_get_all_ports(l4io_get_root_device());
}
+
+int
+l4io_has_resource(enum l4io_resource_types_t type,
+ l4vbus_paddr_t start, l4vbus_paddr_t end)
+{
+ l4io_device_handle_t dh = l4io_get_root_device();
+ l4io_device_t dev;
+ l4io_resource_handle_t reshandle;
+
+ while (1)
+ {
+ l4io_resource_t res;
+
+ if (l4io_iterate_devices(&dh, &dev, &reshandle))
+ break;
+
+ if (dev.num_resources)
+ while (!l4io_lookup_resource(dh, type, &reshandle, &res))
+ if (start >= res.start && end <= res.end)
+ return 1;
+ }
+ return 0;
+}