|
// check if region overlaps with kernel or ramdisk |
|
let kernel_slice_end = kernel_slice_start + kernel_slice_len; |
|
let ramdisk_slice_end = ramdisk_slice_start.map(|s| s + ramdisk_slice_len); |
|
if region.kind == MemoryRegionKind::Usable |
|
&& kernel_slice_start < region.end |
|
&& kernel_slice_end > region.start |
|
{ |
|
// region overlaps with kernel -> we might need to split it |
|
|
|
} else if region.kind == MemoryRegionKind::Usable |
|
&& ramdisk_slice_start.map(|s| s < region.end).unwrap_or(false) |
|
&& ramdisk_slice_end.map(|e| e > region.start).unwrap_or(false) |
|
{ |
This assumes that the memory region containing the kernel and the region containing the ramdisk are distinct. However if both fall within the same region only the kernel is marked as a bootloader region and the ramdisk is marked as usable.