kernel/vm: Clean up vm_allocate_early_physical_page.
Clean up comments, merge assignments with declarations, etc. No functional change intended.
This commit is contained in:
+12
-15
@@ -4341,19 +4341,18 @@ vm_allocate_early_physical_page(kernel_args* args)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try expanding the existing physical ranges upwards.
|
||||||
for (uint32 i = 0; i < args->num_physical_allocated_ranges; i++) {
|
for (uint32 i = 0; i < args->num_physical_allocated_ranges; i++) {
|
||||||
phys_addr_t nextPage;
|
phys_addr_t nextPage = args->physical_allocated_range[i].start
|
||||||
|
|
||||||
nextPage = args->physical_allocated_range[i].start
|
|
||||||
+ args->physical_allocated_range[i].size;
|
+ args->physical_allocated_range[i].size;
|
||||||
// see if the page after the next allocated paddr run can be allocated
|
|
||||||
if (i + 1 < args->num_physical_allocated_ranges
|
// make sure the next page does not collide with the next allocated range
|
||||||
|
if ((i + 1) < args->num_physical_allocated_ranges
|
||||||
&& args->physical_allocated_range[i + 1].size != 0) {
|
&& args->physical_allocated_range[i + 1].size != 0) {
|
||||||
// see if the next page will collide with the next allocated range
|
if (nextPage >= args->physical_allocated_range[i + 1].start)
|
||||||
if (nextPage >= args->physical_allocated_range[i+1].start)
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// see if the next physical page fits in the memory block
|
// see if the next page fits in the memory block
|
||||||
if (is_page_in_physical_memory_range(args, nextPage)) {
|
if (is_page_in_physical_memory_range(args, nextPage)) {
|
||||||
// we got one!
|
// we got one!
|
||||||
args->physical_allocated_range[i].size += B_PAGE_SIZE;
|
args->physical_allocated_range[i].size += B_PAGE_SIZE;
|
||||||
@@ -4363,14 +4362,12 @@ vm_allocate_early_physical_page(kernel_args* args)
|
|||||||
|
|
||||||
// Expanding upwards didn't work, try going downwards.
|
// Expanding upwards didn't work, try going downwards.
|
||||||
for (uint32 i = 0; i < args->num_physical_allocated_ranges; i++) {
|
for (uint32 i = 0; i < args->num_physical_allocated_ranges; i++) {
|
||||||
phys_addr_t nextPage;
|
phys_addr_t nextPage = args->physical_allocated_range[i].start - B_PAGE_SIZE;
|
||||||
|
|
||||||
nextPage = args->physical_allocated_range[i].start - B_PAGE_SIZE;
|
// make sure the next page does not collide with the previous allocated range
|
||||||
// see if the page after the prev allocated paddr run can be allocated
|
if ((i > 0) && args->physical_allocated_range[i - 1].size != 0) {
|
||||||
if (i > 0 && args->physical_allocated_range[i - 1].size != 0) {
|
if (nextPage < args->physical_allocated_range[i - 1].start
|
||||||
// see if the next page will collide with the next allocated range
|
+ args->physical_allocated_range[i - 1].size)
|
||||||
if (nextPage < args->physical_allocated_range[i-1].start
|
|
||||||
+ args->physical_allocated_range[i-1].size)
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// see if the next physical page fits in the memory block
|
// see if the next physical page fits in the memory block
|
||||||
|
|||||||
Reference in New Issue
Block a user