poke: map area into client team in POKE_MAP_MEMORY ioctl

After this change `POKE_UNMAP_MEMORY` ioctl will became redurant and
an alias for `delete_area()`. Areas will be automatically deleted
on team exit.

Change-Id: I336b49c2281abf064e1bf28d908c7b2c5afd4df0
This commit is contained in:
X512
2023-12-23 22:26:26 -05:00
committed by Augustin Cavalier
parent e92b4d3a27
commit 0bb43cbf5a
2 changed files with 10 additions and 12 deletions
+1
View File
@@ -67,4 +67,5 @@ typedef struct {
void* address; void* address;
} mem_map_args; } mem_map_args;
#endif // _POKE_DRIVER_H_ #endif // _POKE_DRIVER_H_
+9 -12
View File
@@ -1,25 +1,22 @@
/* /*
* Copyright 2005, Oscar Lesta. All rights reserved. * Copyright 2005, Oscar Lesta. All rights reserved.
* Copyright 2018, Haiku, Inc. All rights reserved. * Copyright 2018-2023, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#include "poke.h"
#include <Drivers.h> #include <Drivers.h>
#include <KernelExport.h> #include <KernelExport.h>
#include <ISA.h> #include <ISA.h>
#include <PCI.h> #include <PCI.h>
#include <team.h>
#include <vm/vm.h>
#if defined(__i386__) || defined(__x86_64__) #if defined(__i386__) || defined(__x86_64__)
#include <thread.h> #include <thread.h>
#endif #endif
#include "poke.h"
/*
TODO: maintain a list of mapped areas in the cookie
and only allow unmapping them, and clean them up on free.
*/
static status_t poke_open(const char*, uint32, void**); static status_t poke_open(const char*, uint32, void**);
static status_t poke_close(void*); static status_t poke_close(void*);
@@ -304,9 +301,9 @@ poke_control(void* cookie, uint32 op, void* arg, size_t length)
if (user_strlcpy(name, ioctl.name, B_OS_NAME_LENGTH) < B_OK) if (user_strlcpy(name, ioctl.name, B_OS_NAME_LENGTH) < B_OK)
return B_BAD_ADDRESS; return B_BAD_ADDRESS;
ioctl.area = map_physical_memory(name, ioctl.area = vm_map_physical_memory(team_get_current_team_id(), name,
(addr_t)ioctl.physical_address, ioctl.size, ioctl.flags, (void**)&ioctl.address, ioctl.flags, ioctl.size, ioctl.protection,
ioctl.protection, (void**)&ioctl.address); ioctl.physical_address, false);
if (user_memcpy(arg, &ioctl, sizeof(mem_map_args)) != B_OK) if (user_memcpy(arg, &ioctl, sizeof(mem_map_args)) != B_OK)
return B_BAD_ADDRESS; return B_BAD_ADDRESS;
@@ -321,7 +318,7 @@ poke_control(void* cookie, uint32 op, void* arg, size_t length)
if (ioctl.signature != POKE_SIGNATURE) if (ioctl.signature != POKE_SIGNATURE)
return B_BAD_VALUE; return B_BAD_VALUE;
return delete_area(ioctl.area); return _user_delete_area(ioctl.area);
} }
} }