Closed benwei closed 10 years ago
Does your user space get the authority of AHB1_1DEV?
No, I don't know how to make a thread with authority of AHB1_1DEV. Tried something like L4_Map within user/root_thread.c, but there is no any improvement. I would appreciate if you or anyone could give me a hint or example.
Map "AHB1_1DEV" to root thread. And root thread could access it. (Just a hacking for explanation)
diff --git a/kernel/memory.c b/kernel/memory.c
index fe24d5f..ef479e2 100644
--- a/kernel/memory.c
+++ b/kernel/memory.c
@@ -108,9 +108,8 @@ memptr_t mempool_align(int mpid, memptr_t addr)
case MP_MEMPOOL:
case MP_SRAM:
case MP_AHB_RAM:
- return addr_align(addr, CONFIG_SMALLEST_FPAGE_SIZE);
case MP_DEVICES:
- return addr & 0xFFFC0000;
+ return addr_align(addr, CONFIG_SMALLEST_FPAGE_SIZE);
}
return addr_align(addr, CONFIG_SMALLEST_FPAGE_SIZE);
@@ -300,9 +299,14 @@ void as_map_user(as_t *as)
switch (memmap[i].tag) {
case MPT_USER_DATA:
case MPT_USER_TEXT:
+ assign_fpages(as, memmap[i].start,
+ (memmap[i].end - memmap[i].start));
+ case MPT_DEVICES:
/* Create fpages only for user text and user data */
- assign_fpages(as, memmap[i].start,
- (memmap[i].end - memmap[i].start));
+ if (memmap[i].start == 0x40020000)
+ assign_fpages(as, memmap[i].start,
+ (memmap[i].end - memmap[i].start));
+ break;
}
}
}
diff --git a/user/root_thread.c b/user/root_thread.c
index 38effc9..24019cf 100644
--- a/user/root_thread.c
+++ b/user/root_thread.c
@@ -9,6 +9,7 @@
#include <l4/ipc.h>
#include <types.h>
#include <user_runtime.h>
+#include <l4io.h>
extern user_struct user_runtime_start[];
extern user_struct user_runtime_end[];
@@ -79,6 +80,8 @@ void __USER_TEXT __root_thread(kip_t *kip_ptr, utcb_t *utcb_ptr)
L4_ThreadId_t myself = {.raw = utcb_ptr->t_globalid};
char *free_mem = (char *) get_free_base(kip_ptr);
+ printf("0x40020000 = 0x%x\n", *(unsigned int *)0x40020000);
+
for (user_struct *ptr = user_runtime_start; ptr != user_runtime_end; ++ptr) {
L4_ThreadId_t tid;
L4_Word_t stack;
Output:
====================================================
Copyright(C) 2013 The F9 Microkernel Project
====================================================
Git head: fa1e2284b5a74bf2a0dec0c40d5e346f6338db6e
Host: x86_64
Build: 2014-04-21T14:47:59+0800
Press '?' to print KDB menu
0x40020000 = 0xa800000a
L4/Pistachio test suite starts
Simple IPC test (inter-as, only untyped words)
Send Message transfer: OK
ReplyWait Message transfer: OK
Returned Id 0 != 0 (local) [0 (global)]
From parameter (local): FAILED
#
However, I still do not know the meaning of mask 0xFFFC0000 for MP_DEVICES.
@jserv , could you explain this?
Thanks.
Thank for georgekang's hint. It's great. I'm going to try this mechanism for moving gpio driver to user-space this weekend.
@georgekang : It was a historical reason when F9 was prototyping on earlier CM4 cores. You can map the device to any valid address for root task.
After commit 635d63b5005f2137c6b600d86ea20762bc3fbbce, I think the root thread already exposes enough address space maps for accessing GPIOs. So, I close this issue first.
I'm trying to modify the PR #86 move the gpio driver (gpio.c with __USER_TEXT)
Unfortunately, Memory fault occurred at 40023830 this address is accessed by gpio_config()
after gcc -E expended
even though I have grant memory.c memmap table from
to
kernel dump show that user can read/write
Are there any idea?