mmap: support device mapping (in progress) refs #218
This commit is contained in:
@@ -778,9 +778,21 @@ static int pager_req_create(ihk_os_t os, int fd, uintptr_t result_pa)
|
|||||||
struct pager *pager = NULL;
|
struct pager *pager = NULL;
|
||||||
struct pager *newpager = NULL;
|
struct pager *newpager = NULL;
|
||||||
uintptr_t phys;
|
uintptr_t phys;
|
||||||
|
struct kstat st;
|
||||||
|
|
||||||
dprintk("pager_req_create(%d,%lx)\n", fd, (long)result_pa);
|
dprintk("pager_req_create(%d,%lx)\n", fd, (long)result_pa);
|
||||||
|
|
||||||
|
error = vfs_fstat(fd, &st);
|
||||||
|
if (error) {
|
||||||
|
printk("pager_req_create(%d,%lx):vfs_stat failed. %d\n", fd, (long)result_pa, error);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
if (!S_ISREG(st.mode)) {
|
||||||
|
error = -ESRCH;
|
||||||
|
printk("pager_req_create(%d,%lx):not VREG. %x\n", fd, (long)result_pa, st.mode);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
file = fget(fd);
|
file = fget(fd);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
error = -EBADF;
|
error = -EBADF;
|
||||||
|
|||||||
@@ -812,6 +812,32 @@ SYSCALL_DECLARE(mmap)
|
|||||||
if (!(flags & MAP_ANONYMOUS)) {
|
if (!(flags & MAP_ANONYMOUS)) {
|
||||||
off = off0;
|
off = off0;
|
||||||
error = fileobj_create(fd, &memobj, &maxprot);
|
error = fileobj_create(fd, &memobj, &maxprot);
|
||||||
|
#ifdef ATTACHED_MIC
|
||||||
|
/*
|
||||||
|
* XXX: refuse device mapping in attached-mic now:
|
||||||
|
*
|
||||||
|
* In attached-mic, ihk_mc_map_memory() cannot convert into a local
|
||||||
|
* physical address a remote physical address which point KNC's memory.
|
||||||
|
* It seems that ihk_mc_map_memory() needs to set up SMPT.
|
||||||
|
*/
|
||||||
|
if (error == -ESRCH) {
|
||||||
|
error = -ENODEV;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (error == -ESRCH) {
|
||||||
|
kprintf("sys_mmap:hit non VREG\n");
|
||||||
|
/*
|
||||||
|
* XXX: temporary:
|
||||||
|
*
|
||||||
|
* device mappings are uncachable
|
||||||
|
* until memory type setting codes are implemented.
|
||||||
|
*/
|
||||||
|
if (1) {
|
||||||
|
vrflags &= ~VR_MEMTYPE_MASK;
|
||||||
|
vrflags |= VR_MEMTYPE_UC;
|
||||||
|
}
|
||||||
|
error = devobj_create(fd, len, off, &memobj, &maxprot);
|
||||||
|
}
|
||||||
if (error) {
|
if (error) {
|
||||||
ekprintf("sys_mmap:fileobj_create failed. %d\n", error);
|
ekprintf("sys_mmap:fileobj_create failed. %d\n", error);
|
||||||
goto out;
|
goto out;
|
||||||
|
|||||||
Reference in New Issue
Block a user