Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102786014
D42724.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D42724.diff
View Options
diff --git a/sys/arm64/arm64/nexus.c b/sys/arm64/arm64/nexus.c
--- a/sys/arm64/arm64/nexus.c
+++ b/sys/arm64/arm64/nexus.c
@@ -462,7 +462,8 @@
struct resource_map_request *argsp, struct resource_map *map)
{
struct resource_map_request args;
- rman_res_t end, length, start;
+ rman_res_t length, start;
+ int error;
/* Resources must be active to be mapped. */
if ((rman_get_flags(r) & RF_ACTIVE) == 0)
@@ -478,18 +479,9 @@
}
resource_init_map_request(&args);
- if (argsp != NULL)
- bcopy(argsp, &args, imin(argsp->size, args.size));
- start = rman_get_start(r) + args.offset;
- if (args.length == 0)
- length = rman_get_size(r);
- else
- length = args.length;
- end = start + length - 1;
- if (start > rman_get_end(r) || start < rman_get_start(r))
- return (EINVAL);
- if (end > rman_get_end(r) || end < start)
- return (EINVAL);
+ error = resource_validate_map_request(r, argsp, &args, &start, &length);
+ if (error)
+ return (error);
map->r_vaddr = pmap_mapdev_attr(start, length, args.memattr);
map->r_bustag = &memmap_bus;
diff --git a/sys/powerpc/powerpc/nexus.c b/sys/powerpc/powerpc/nexus.c
--- a/sys/powerpc/powerpc/nexus.c
+++ b/sys/powerpc/powerpc/nexus.c
@@ -353,9 +353,9 @@
nexus_map_resource(device_t bus, device_t child, int type, struct resource *r,
struct resource_map_request *argsp, struct resource_map *map)
{
-
struct resource_map_request args;
- rman_res_t end, length, start;
+ rman_res_t length, start;
+ int error;
/* Resources must be active to be mapped. */
if (!(rman_get_flags(r) & RF_ACTIVE))
@@ -371,21 +371,9 @@
}
resource_init_map_request(&args);
- if (argsp != NULL)
- bcopy(argsp, &args, imin(argsp->size, args.size));
-
- start = rman_get_start(r) + args.offset;
- if (args.length == 0)
- length = rman_get_size(r);
- else
- length = args.length;
-
- end = start + length - 1;
- if (start > rman_get_end(r) || start < rman_get_start(r))
- return (EINVAL);
-
- if (end > rman_get_end(r) || end < start)
- return (EINVAL);
+ error = resource_validate_map_request(r, argsp, &args, &start, &length);
+ if (error)
+ return (error);
/*
* If this is a memory resource, map it into the kernel.
diff --git a/sys/riscv/riscv/nexus.c b/sys/riscv/riscv/nexus.c
--- a/sys/riscv/riscv/nexus.c
+++ b/sys/riscv/riscv/nexus.c
@@ -424,7 +424,8 @@
struct resource_map_request *argsp, struct resource_map *map)
{
struct resource_map_request args;
- rman_res_t end, length, start;
+ rman_res_t length, start;
+ int error;
/* Resources must be active to be mapped. */
if ((rman_get_flags(r) & RF_ACTIVE) == 0)
@@ -440,18 +441,9 @@
}
resource_init_map_request(&args);
- if (argsp != NULL)
- bcopy(argsp, &args, imin(argsp->size, args.size));
- start = rman_get_start(r) + args.offset;
- if (args.length == 0)
- length = rman_get_size(r);
- else
- length = args.length;
- end = start + length - 1;
- if (start > rman_get_end(r) || start < rman_get_start(r))
- return (EINVAL);
- if (end > rman_get_end(r) || end < start)
- return (EINVAL);
+ error = resource_validate_map_request(r, argsp, &args, &start, &length);
+ if (error)
+ return (error);
map->r_vaddr = pmap_mapdev(start, length);
map->r_bustag = &memmap_bus;
diff --git a/sys/x86/x86/nexus.c b/sys/x86/x86/nexus.c
--- a/sys/x86/x86/nexus.c
+++ b/sys/x86/x86/nexus.c
@@ -458,7 +458,8 @@
struct resource_map_request *argsp, struct resource_map *map)
{
struct resource_map_request args;
- rman_res_t end, length, start;
+ rman_res_t length, start;
+ int error;
/* Resources must be active to be mapped. */
if (!(rman_get_flags(r) & RF_ACTIVE))
@@ -474,18 +475,9 @@
}
resource_init_map_request(&args);
- if (argsp != NULL)
- bcopy(argsp, &args, imin(argsp->size, args.size));
- start = rman_get_start(r) + args.offset;
- if (args.length == 0)
- length = rman_get_size(r);
- else
- length = args.length;
- end = start + length - 1;
- if (start > rman_get_end(r) || start < rman_get_start(r))
- return (EINVAL);
- if (end > rman_get_end(r) || end < start)
- return (EINVAL);
+ error = resource_validate_map_request(r, argsp, &args, &start, &length);
+ if (error)
+ return (error);
/*
* If this is a memory resource, map it into the kernel.
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 18, 4:26 AM (21 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14689771
Default Alt Text
D42724.diff (4 KB)
Attached To
Mode
D42724: nexus: Use resource_validate_map_request
Attached
Detach File
Event Timeline
Log In to Comment