From cbb5d6d9d888e43f29d736f6f39b7917af6b1c2a Mon Sep 17 00:00:00 2001 From: Akira Moroo Date: Fri, 5 Mar 2021 17:09:29 +0900 Subject: [PATCH 1/6] build: Update toolchain to nightly-2021-03-04 Signed-off-by: Akira Moroo --- .travis.yml | 2 +- rust-toolchain | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 38d6a406..606f3535 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ dist: xenial language: rust rust: - - nightly-2020-10-01 + - nightly-2021-03-04 env: - RUSTFLAGS="-D warnings" diff --git a/rust-toolchain b/rust-toolchain index fe5455cb..d59ceb61 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-10-01 +nightly-2021-03-04 From e6eed92df3afd5293718905a2e266a0438b653ca Mon Sep 17 00:00:00 2001 From: Akira Moroo Date: Fri, 5 Mar 2021 17:10:24 +0900 Subject: [PATCH 2/6] build: Update x86_64 and uart_16550 These dependencies require update for updating Rust toolchain. Signed-off-by: Akira Moroo --- Cargo.lock | 24 ++++++++---------------- Cargo.toml | 4 ++-- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e8c47415..d8eefdfd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "atomic_refcell" version = "0.1.6" @@ -74,7 +76,7 @@ dependencies = [ "ssh2", "tempfile", "uart_16550", - "x86_64 0.13.1", + "x86_64", ] [[package]] @@ -295,12 +297,12 @@ dependencies = [ [[package]] name = "uart_16550" -version = "0.2.10" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb00b16a4c8acbfc4eb8cfeda1f9c0507c7e87c6563edce64a236af93acf70c" +checksum = "8d45a3c9181dc9ba7d35d02b3c36d1604155289d935b7946510fb3d2f4b976d9" dependencies = [ "bitflags", - "x86_64 0.12.4", + "x86_64", ] [[package]] @@ -339,19 +341,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "x86_64" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3a6840d540b8dbe400f4ed5afe5816105ee5edebe485299a761d0d8b43cef7" -dependencies = [ - "bit_field", - "bitflags", -] - -[[package]] -name = "x86_64" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d74944372d63f31dd39fce1ef8036143484ff4cd4efcd743ef50135839de4e7" +checksum = "b871116e3c83dad0795580b10b2b1dd05cb52ec719af36180371877b09681f7f" dependencies = [ "bit_field", "bitflags", diff --git a/Cargo.toml b/Cargo.toml index eddbc9d7..4410e962 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,10 +26,10 @@ coreboot = [] [dependencies] bitflags = "1.2" -x86_64 = "0.13.1" +x86_64 = "0.13.2" atomic_refcell = "0.1" r-efi = "3.2.0" -uart_16550 = "0.2.10" +uart_16550 = "0.2.12" linked_list_allocator = "0.8.11" [dev-dependencies] From 21aabb95df599f82083a86b7c551144f5a174ebd Mon Sep 17 00:00:00 2001 From: Akira Moroo Date: Fri, 5 Mar 2021 17:13:40 +0900 Subject: [PATCH 3/6] build: Remove const_in_array_repeat_expressions The `const_in_array_repeat_expressions` feature has been removed from Rust [rust-lang/rust #80404](https://github.com/rust-lang/rust/pull/80404). Signed-off-by: Akira Moroo --- src/main.rs | 2 +- src/paging.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8de0c6eb..73b62825 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,7 @@ // limitations under the License. #![feature(alloc_error_handler)] -#![feature(global_asm, const_in_array_repeat_expressions)] +#![feature(global_asm)] #![cfg_attr(not(test), no_std)] #![cfg_attr(not(test), no_main)] #![cfg_attr(test, allow(unused_imports, dead_code))] diff --git a/src/paging.rs b/src/paging.rs index 448ede42..d185dfd4 100644 --- a/src/paging.rs +++ b/src/paging.rs @@ -6,6 +6,7 @@ use x86_64::{ // Amount of memory we identity map in setup(), max 512 GiB. const ADDRESS_SPACE_GIB: usize = 4; +const TABLE: PageTable = PageTable::new(); // Put the Page Tables in static muts to make linking easier #[no_mangle] @@ -13,7 +14,7 @@ static mut L4_TABLE: PageTable = PageTable::new(); #[no_mangle] static mut L3_TABLE: PageTable = PageTable::new(); #[no_mangle] -static mut L2_TABLES: [PageTable; ADDRESS_SPACE_GIB] = [PageTable::new(); ADDRESS_SPACE_GIB]; +static mut L2_TABLES: [PageTable; ADDRESS_SPACE_GIB] = [TABLE; ADDRESS_SPACE_GIB]; pub fn setup() { // SAFETY: This function is idempontent and only writes to static memory and From 78643c8c2d6a4adc5d93b35b3948a351e48d3824 Mon Sep 17 00:00:00 2001 From: Akira Moroo Date: Fri, 5 Mar 2021 17:17:19 +0900 Subject: [PATCH 4/6] build: Allow unread fields in structs Signed-off-by: Akira Moroo --- src/efi/file.rs | 1 + src/fat.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/efi/file.rs b/src/efi/file.rs index 43a3c285..02dc2dee 100644 --- a/src/efi/file.rs +++ b/src/efi/file.rs @@ -136,6 +136,7 @@ pub extern "win64" fn set_position(_: *mut FileProtocol, _: u64) -> Status { Status::UNSUPPORTED } +#[allow(unused)] struct FileInfo { size: u64, file_size: u64, diff --git a/src/fat.rs b/src/fat.rs index 0dd0c78a..40347398 100644 --- a/src/fat.rs +++ b/src/fat.rs @@ -104,6 +104,7 @@ pub struct Filesystem<'a> { first_fat_sector: u32, first_data_sector: u32, data_sector_count: u32, + #[allow(unused)] data_cluster_count: u32, root_cluster: u32, // FAT32 only } From 715930594d8ddb995378035b383904509f8bc3d7 Mon Sep 17 00:00:00 2001 From: Akira Moroo Date: Fri, 5 Mar 2021 17:27:48 +0900 Subject: [PATCH 5/6] efi: Remove unnecessary cast clippy suggests removal of unnecessary casting integer literal to `u64`. Signed-off-by: Akira Moroo --- src/efi/block.rs | 2 +- src/efi/file.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/efi/block.rs b/src/efi/block.rs index 4c55a4cc..102abf64 100644 --- a/src/efi/block.rs +++ b/src/efi/block.rs @@ -190,7 +190,7 @@ impl<'a> BlockWrapper<'a> { AllocateType::AllocateAnyPages, MemoryType::LoaderData, ((size + super::PAGE_SIZE as usize - 1) / super::PAGE_SIZE as usize) as u64, - 0 as u64, + 0_u64, ); let bw = new_address as *mut BlockWrapper; diff --git a/src/efi/file.rs b/src/efi/file.rs index 02dc2dee..427747b0 100644 --- a/src/efi/file.rs +++ b/src/efi/file.rs @@ -213,7 +213,7 @@ impl<'a> FileSystemWrapper<'a> { AllocateType::AllocateAnyPages, MemoryType::LoaderData, ((size + super::PAGE_SIZE as usize - 1) / super::PAGE_SIZE as usize) as u64, - 0 as u64, + 0_u64, ); if status == Status::SUCCESS { From ba1e9f34aec2d1a591e2a39680e8bd3b3cde14d4 Mon Sep 17 00:00:00 2001 From: Akira Moroo Date: Fri, 5 Mar 2021 17:30:27 +0900 Subject: [PATCH 6/6] fat, part: Fix non-string literal panic message clippy says that `panic!(e)` is no longer accepted in Rust 2021. Signed-off-by: Akira Moroo --- src/fat.rs | 16 ++++++++-------- src/part.rs | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/fat.rs b/src/fat.rs index 40347398..0fe393a1 100644 --- a/src/fat.rs +++ b/src/fat.rs @@ -676,7 +676,7 @@ mod tests { Err(super::Error::EndOfFile) => { break; } - Err(e) => panic!(e), + Err(e) => panic!("{:?}", e), } } @@ -714,7 +714,7 @@ mod tests { Err(super::Error::EndOfFile) => { break; } - Err(e) => panic!(e), + Err(e) => panic!("{:?}", e), } } @@ -731,7 +731,7 @@ mod tests { Err(super::Error::EndOfFile) => { break; } - Err(e) => panic!(e), + Err(e) => panic!("{:?}", e), } } @@ -749,7 +749,7 @@ mod tests { Err(super::Error::EndOfFile) => { break; } - Err(e) => panic!(e), + Err(e) => panic!("{:?}", e), } } assert_eq!(bytes_so_far, f.size); @@ -770,10 +770,10 @@ mod tests { assert_eq!(f.sectors, 1_046_528); assert_eq!(f.fat_type, super::FatType::FAT16); } - Err(e) => panic!(e), + Err(e) => panic!("{:?}", e), } } - Err(e) => panic!(e), + Err(e) => panic!("{:?}", e), } } @@ -789,10 +789,10 @@ mod tests { assert_eq!(file.active_cluster, 166); assert_eq!(file.size, 92789); } - Err(e) => panic!(e), + Err(e) => panic!("{:?}", e), } } - Err(e) => panic!(e), + Err(e) => panic!("{:?}", e), } } diff --git a/src/part.rs b/src/part.rs index b7e73ead..706297fc 100644 --- a/src/part.rs +++ b/src/part.rs @@ -199,7 +199,7 @@ pub mod tests { assert_eq!(start, 2048); assert_eq!(end, 1_048_575); } - Err(e) => panic!(e), + Err(e) => panic!("{:?}", e), } } }