Hi,
I've implemented my own rom service based on Genode::Rom_root and Genode::Rom_fs inside a server. Basically the service seems to work.
If I open a Rom_connection on a file that I've added to my Rom_fs before, I get a valid Dataspace_capability.
By using a Genode::Dataspace_client, I can see that the size and the base address of the Dataspace correspond to the values that I've passed to the Rom_module I've inserted into my Rom_fs before.
The problem is, that the data inside the Dataspace is 0. Here the code:
Dataspace_capability file_cap; Rom_connection rom(filename, unique_name); try { file_cap = rom.dataspace(); } catch (Rom_file_missing) { printf("Error: Could not access file "%s" from ROM service.\n", filename); return 0; }
if(!file_cap.valid()) PWRN("file cap not valid!!"); void* addr = env()->rm_session()->attach(file_cap); Genode::Dataspace_client dsc(file_cap); PDBG("rom module filename: %s", filename); PDBG("rom module base address: 0x%lx", dsc.phys_addr()); PDBG("rom module size: 0x%zx", dsc.size()); PDBG("some data: 0x%x", *(int*)addr);
.. and the corresponding output: rom module filename: pci_drv rom module base address: 0x3333000 rom module size: 0x26000 some data: 0x0
My understanding is, that the constructor of Rom_module needs a physical base address. How can I copy data to a memory location, that is still available in another context?
I've tried out the following but this does not work:
// for now we copy data from core's to our local rom service Genode::Dataspace_capability file_cap; Rom_connection rom(filename); try { file_cap = rom.dataspace(); } catch (Rom_file_missing) { printf("Error: Could not access file "%s" from ROM service.\n", filename); }
void* addr = env()->rm_session()->attach(file_cap); Genode::Dataspace_client dsc_source(file_cap);
/* create new Rom_module */ Genode::Ram_dataspace *ram_dsc = new (env()->heap()) Genode::Ram_dataspace(env()->ram_session(), dsc_source.size()); Genode::Dataspace_client dsc(ram_dsc->cap());
Genode::memcpy(ram_dsc->local_addr<void>(), addr, dsc_source.size());
Rom_module *r = new (&_sliced_heap) Rom_module(dsc.phys_addr(), dsc_source.size(), filename); PDBG("rom module filename: %s", filename); PDBG("rom module base address: 0x%lx", dsc_source.phys_addr()); PDBG("rom module size: 0x%zx", dsc_source.size()); PDBG("dataspace base address: 0x%lx", dsc.phys_addr()); PDBG("some data: 0x%x", *(int*)ram_dsc->local_addr<void>()); _rom_fs.insert(r); _rom_fs.print_fs();
The output in this context is ok: rom module filename: pci_drv rom module base address: 0x3140000 rom module size: 0x26000 dataspace base address: 0x3333000 some data: 0x464c457f
Is there an Allocator that I can use?
Thx,
Oliver