Skip to content

Commit 2419f2f

Browse files
authored
Merge pull request #490 from ChocolateLoverRaj/cargo-1.86.0-nightly
Update `x86_64` to `0.15.2`
2 parents 5d06f60 + 449d31e commit 2419f2f

File tree

20 files changed

+86
-73
lines changed

20 files changed

+86
-73
lines changed

Cargo.lock

+25-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bios/stage-4/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ bootloader-x86_64-common = { workspace = true }
1414
bootloader-x86_64-bios-common = { workspace = true }
1515
bootloader-boot-config = { workspace = true }
1616
log = "0.4.14"
17-
x86_64 = "0.14.8"
17+
x86_64 = "0.15.2"
1818
rsdp = "2.0.0"
1919
usize_conversions = "0.2.0"
2020
serde-json-core = "0.5.0"

common/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ bootloader-boot-config = { workspace = true }
1414
conquer-once = { version = "0.3.2", default-features = false }
1515
spinning_top = "0.2.4"
1616
usize_conversions = "0.2.0"
17-
x86_64 = { version = "0.14.8" }
17+
x86_64 = { version = "0.15.2" }
1818
xmas-elf = "0.8.0"
1919
raw-cpuid = "10.2.0"
2020
rand = { version = "0.8.4", default-features = false }

common/src/gdt.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ pub fn create_and_load(frame: PhysFrame) {
1515
let ptr: *mut GlobalDescriptorTable = virt_addr.as_mut_ptr();
1616

1717
let mut gdt = GlobalDescriptorTable::new();
18-
let code_selector = gdt.add_entry(Descriptor::kernel_code_segment());
19-
let data_selector = gdt.add_entry(Descriptor::kernel_data_segment());
18+
let code_selector = gdt.append(Descriptor::kernel_code_segment());
19+
let data_selector = gdt.append(Descriptor::kernel_data_segment());
2020
let gdt = unsafe {
2121
ptr.write(gdt);
2222
&*ptr

common/src/level_4_entries.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,18 @@ impl UsedLevel4Entries {
4848

4949
// The bootload needs to access the frame buffer.
5050
if let Some(frame_buffer) = framebuffer {
51-
used.mark_range_as_used(frame_buffer.addr.as_u64(), frame_buffer.info.byte_len);
51+
used.mark_range_as_used(
52+
frame_buffer.addr.as_u64(),
53+
frame_buffer.info.byte_len as u64,
54+
);
5255
}
5356

5457
// Mark the statically configured ranges from the config as used.
5558

5659
if let Some(config::Mapping::FixedAddress(physical_memory_offset)) =
5760
config.mappings.physical_memory
5861
{
59-
used.mark_range_as_used(physical_memory_offset, max_phys_addr.as_u64().into_usize());
62+
used.mark_range_as_used(physical_memory_offset, max_phys_addr.as_u64());
6063
}
6164

6265
if let Some(config::Mapping::FixedAddress(recursive_address)) =
@@ -76,12 +79,12 @@ impl UsedLevel4Entries {
7679
let memory_regions_layout = Layout::array::<MemoryRegion>(regions).unwrap();
7780
let (combined, _) = boot_info_layout.extend(memory_regions_layout).unwrap();
7881

79-
used.mark_range_as_used(boot_info_address, combined.size());
82+
used.mark_range_as_used(boot_info_address, combined.size() as u64);
8083
}
8184

8285
if let config::Mapping::FixedAddress(framebuffer_address) = config.mappings.framebuffer {
8386
if let Some(framebuffer) = framebuffer {
84-
used.mark_range_as_used(framebuffer_address, framebuffer.info.byte_len);
87+
used.mark_range_as_used(framebuffer_address, framebuffer.info.byte_len as u64);
8588
}
8689
}
8790

@@ -111,14 +114,9 @@ impl UsedLevel4Entries {
111114
}
112115

113116
/// Marks all p4 entries in the range `[address..address+size)` as used.
114-
///
115-
/// `size` can be a `u64` or `usize`.
116-
fn mark_range_as_used<S>(&mut self, address: u64, size: S)
117-
where
118-
VirtAddr: core::ops::Add<S, Output = VirtAddr>,
119-
{
117+
fn mark_range_as_used(&mut self, address: u64, size: u64) {
120118
let start = VirtAddr::new(address);
121-
let end_inclusive = (start + size) - 1usize;
119+
let end_inclusive = (start + size) - 1;
122120
let start_page = Page::<Size4KiB>::containing_address(start);
123121
let end_page_inclusive = Page::<Size4KiB>::containing_address(end_inclusive);
124122

common/src/lib.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,9 @@ where
285285
log::info!("Map framebuffer");
286286

287287
let framebuffer_start_frame: PhysFrame = PhysFrame::containing_address(framebuffer.addr);
288-
let framebuffer_end_frame =
289-
PhysFrame::containing_address(framebuffer.addr + framebuffer.info.byte_len - 1u64);
288+
let framebuffer_end_frame = PhysFrame::containing_address(
289+
framebuffer.addr + framebuffer.info.byte_len as u64 - 1u64,
290+
);
290291
let start_page = mapping_addr_page_aligned(
291292
config.mappings.framebuffer,
292293
u64::from_usize(framebuffer.info.byte_len),
@@ -394,7 +395,7 @@ where
394395
}
395396
};
396397

397-
let entry = &mut kernel_page_table.level_4_table()[index];
398+
let entry = &mut kernel_page_table.level_4_table_mut()[index];
398399
if !entry.is_unused() {
399400
panic!(
400401
"Could not set up recursive mapping: index {} already in use",
@@ -496,8 +497,8 @@ where
496497
)
497498
.expect("boot info addr is not properly aligned");
498499

499-
let memory_map_regions_addr = boot_info_addr + memory_regions_offset;
500-
let memory_map_regions_end = boot_info_addr + combined.size();
500+
let memory_map_regions_addr = boot_info_addr + memory_regions_offset as u64;
501+
let memory_map_regions_end = boot_info_addr + combined.size() as u64;
501502

502503
let start_page = Page::containing_address(boot_info_addr);
503504
let end_page = Page::containing_address(memory_map_regions_end - 1u64);

common/src/load_kernel.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,8 @@ where
342342
let end_inclusive_copy_address = cmp::min(end_inclusive_addr, page_end_inclusive);
343343

344344
// These are the offsets into the frame we want to copy from.
345-
let start_offset_in_frame = (start_copy_address - page_start) as usize;
346-
let end_inclusive_offset_in_frame = (end_inclusive_copy_address - page_start) as usize;
345+
let start_offset_in_frame = start_copy_address - page_start;
346+
let end_inclusive_offset_in_frame = end_inclusive_copy_address - page_start;
347347

348348
// Calculate how many bytes we want to copy from this frame.
349349
let copy_len = end_inclusive_offset_in_frame - start_offset_in_frame + 1;
@@ -362,11 +362,11 @@ where
362362
// SAFETY: We know that this memory is valid because we got it
363363
// as a result from a translation. There are not other
364364
// references to it.
365-
&*core::ptr::slice_from_raw_parts(src_ptr, copy_len)
365+
&*core::ptr::slice_from_raw_parts(src_ptr, copy_len as usize)
366366
};
367367

368368
// Calculate the destination pointer.
369-
let dest = &mut buf[start_offset_in_buf..][..copy_len];
369+
let dest = &mut buf[start_offset_in_buf..][..copy_len as usize];
370370

371371
// Do the actual copy.
372372
dest.copy_from_slice(src);
@@ -409,8 +409,8 @@ where
409409
let end_inclusive_copy_address = cmp::min(end_inclusive_addr, page_end_inclusive);
410410

411411
// These are the offsets into the frame we want to copy from.
412-
let start_offset_in_frame = (start_copy_address - page_start) as usize;
413-
let end_inclusive_offset_in_frame = (end_inclusive_copy_address - page_start) as usize;
412+
let start_offset_in_frame = start_copy_address - page_start;
413+
let end_inclusive_offset_in_frame = end_inclusive_copy_address - page_start;
414414

415415
// Calculate how many bytes we want to copy from this frame.
416416
let copy_len = end_inclusive_offset_in_frame - start_offset_in_frame + 1;
@@ -429,11 +429,11 @@ where
429429
// SAFETY: We know that this memory is valid because we got it
430430
// as a result from a translation. There are not other
431431
// references to it.
432-
&mut *core::ptr::slice_from_raw_parts_mut(dest_ptr, copy_len)
432+
&mut *core::ptr::slice_from_raw_parts_mut(dest_ptr, copy_len as usize)
433433
};
434434

435435
// Calculate the destination pointer.
436-
let src = &buf[start_offset_in_buf..][..copy_len];
436+
let src = &buf[start_offset_in_buf..][..copy_len as usize];
437437

438438
// Do the actual copy.
439439
dest.copy_from_slice(src);

0 commit comments

Comments
 (0)