summaryrefslogtreecommitdiffstats
path: root/rsnix
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--rsnix/src/fat.rs6
-rw-r--r--rsnix/src/fs.rs10
-rw-r--r--rsnix/src/interrupts.rs4
-rw-r--r--rsnix/src/memory.rs2
-rw-r--r--rsnix/src/paging.rs2
-rw-r--r--rsnix/src/pci.rs6
-rw-r--r--rsnix/src/power.rs2
-rw-r--r--rsnix/src/vt.rs8
8 files changed, 13 insertions, 27 deletions
diff --git a/rsnix/src/fat.rs b/rsnix/src/fat.rs
index 13d19df..335a160 100644
--- a/rsnix/src/fat.rs
+++ b/rsnix/src/fat.rs
@@ -153,11 +153,7 @@ fn is_eoc(c: u32) -> bool {
153 153
154fn next_cluster(c: u32) -> Result<u32, ()> { 154fn next_cluster(c: u32) -> Result<u32, ()> {
155 let n = read_fat_entry(c); 155 let n = read_fat_entry(c);
156 if is_eoc(n) { 156 if is_eoc(n) { Err(()) } else { Ok(n) }
157 Err(())
158 } else {
159 Ok(n)
160 }
161} 157}
162 158
163/// Allocate a fresh cluster: mark it EOC in the FAT and zero its data. 159/// Allocate a fresh cluster: mark it EOC in the FAT and zero its data.
diff --git a/rsnix/src/fs.rs b/rsnix/src/fs.rs
index 2a1a3e3..a71e51a 100644
--- a/rsnix/src/fs.rs
+++ b/rsnix/src/fs.rs
@@ -92,10 +92,10 @@ fn add(name: &str, parent: Option<usize>, kind: FileType, data: NodeData) -> usi
92 data, 92 data,
93 removed: false, 93 removed: false,
94 }); 94 });
95 if let Some(p) = parent { 95 if let Some(p) = parent
96 if let NodeData::Dir(v) = &mut nodes()[p].data { 96 && let NodeData::Dir(v) = &mut nodes()[p].data
97 v.push(h); 97 {
98 } 98 v.push(h);
99 } 99 }
100 h 100 h
101} 101}
@@ -224,7 +224,7 @@ pub fn resolve(path: &str) -> Option<usize> {
224 return None; 224 return None;
225 } 225 }
226 let mut cur = 0usize; // root 226 let mut cur = 0usize; // root
227 // (vol, cluster, parent, name) of directories descended into under /disk. 227 // (vol, cluster, parent, name) of directories descended into under /disk.
228 let mut dstack: Vec<(usize, u32, u32, String)> = Vec::new(); 228 let mut dstack: Vec<(usize, u32, u32, String)> = Vec::new();
229 for seg in path.split('/') { 229 for seg in path.split('/') {
230 match seg { 230 match seg {
diff --git a/rsnix/src/interrupts.rs b/rsnix/src/interrupts.rs
index cbd234e..2b82a3d 100644
--- a/rsnix/src/interrupts.rs
+++ b/rsnix/src/interrupts.rs
@@ -256,7 +256,7 @@ struct IntFrame {
256} 256}
257 257
258/// Called from the asm common handler — dispatches to the right Rust handler. 258/// Called from the asm common handler — dispatches to the right Rust handler.
259#[no_mangle] 259#[unsafe(no_mangle)]
260unsafe extern "C" fn isr_dispatch(frame: &IntFrame) { 260unsafe extern "C" fn isr_dispatch(frame: &IntFrame) {
261 unsafe { 261 unsafe {
262 match frame.vector { 262 match frame.vector {
@@ -344,7 +344,7 @@ pub fn init() {
344// --------------------------------------------------------------------------- 344// ---------------------------------------------------------------------------
345// Extern symbols from global_asm! 345// Extern symbols from global_asm!
346// --------------------------------------------------------------------------- 346// ---------------------------------------------------------------------------
347extern "C" { 347unsafe extern "C" {
348 fn isr_stub_32(); 348 fn isr_stub_32();
349 fn isr_stub_33(); 349 fn isr_stub_33();
350 fn isr_stub_spurious(); 350 fn isr_stub_spurious();
diff --git a/rsnix/src/memory.rs b/rsnix/src/memory.rs
index 54ff7be..7c3eda0 100644
--- a/rsnix/src/memory.rs
+++ b/rsnix/src/memory.rs
@@ -89,7 +89,7 @@ fn align_up(x: usize, a: usize) -> usize {
89unsafe fn free_list_insert(block: *mut Header) { 89unsafe fn free_list_insert(block: *mut Header) {
90 let addr = block as usize; 90 let addr = block as usize;
91 let mut prev: *mut Header = ptr::null_mut(); 91 let mut prev: *mut Header = ptr::null_mut();
92 let mut cur = FREE_LIST; 92 let mut cur = unsafe { FREE_LIST };
93 while !cur.is_null() && (cur as usize) < addr { 93 while !cur.is_null() && (cur as usize) < addr {
94 prev = cur; 94 prev = cur;
95 cur = unsafe { (*(*cur).links()).next }; 95 cur = unsafe { (*(*cur).links()).next };
diff --git a/rsnix/src/paging.rs b/rsnix/src/paging.rs
index 766bde3..d786dee 100644
--- a/rsnix/src/paging.rs
+++ b/rsnix/src/paging.rs
@@ -12,7 +12,7 @@
12// refcounting) — fine for a kernel that owns all memory. 12// refcounting) — fine for a kernel that owns all memory.
13// --------------------------------------------------------------------------- 13// ---------------------------------------------------------------------------
14 14
15use crate::memory::{alloc_pages, free_pages, PAGE_SIZE}; 15use crate::memory::{PAGE_SIZE, alloc_pages, free_pages};
16 16
17pub const PAGE_PRESENT: u64 = 1 << 0; 17pub const PAGE_PRESENT: u64 = 1 << 0;
18pub const PAGE_WRITABLE: u64 = 1 << 1; 18pub const PAGE_WRITABLE: u64 = 1 << 1;
diff --git a/rsnix/src/pci.rs b/rsnix/src/pci.rs
index efdbc01..21d7536 100644
--- a/rsnix/src/pci.rs
+++ b/rsnix/src/pci.rs
@@ -83,11 +83,7 @@ pub fn bar64(bus: u8, device: u8, func: u8, bar_index: u8) -> Option<u64> {
83 0 83 0
84 }; 84 };
85 let base = ((hi as u64) << 32) | (lo as u64 & 0xFFFF_FFF0); 85 let base = ((hi as u64) << 32) | (lo as u64 & 0xFFFF_FFF0);
86 if base == 0 { 86 if base == 0 { None } else { Some(base) }
87 None
88 } else {
89 Some(base)
90 }
91} 87}
92 88
93/// Enumerate every device/function present on all buses. 89/// Enumerate every device/function present on all buses.
diff --git a/rsnix/src/power.rs b/rsnix/src/power.rs
index cb5d296..3ca0f25 100644
--- a/rsnix/src/power.rs
+++ b/rsnix/src/power.rs
@@ -9,7 +9,7 @@
9// QEMU this makes the VM exit, on real hardware the power drops. 9// QEMU this makes the VM exit, on real hardware the power drops.
10// --------------------------------------------------------------------------- 10// ---------------------------------------------------------------------------
11 11
12use crate::uefi::{RuntimeServices, EFI_SUCCESS, RESET_SHUTDOWN}; 12use crate::uefi::{EFI_SUCCESS, RESET_SHUTDOWN, RuntimeServices};
13 13
14static mut RUNTIME_SERVICES: *mut RuntimeServices = core::ptr::null_mut(); 14static mut RUNTIME_SERVICES: *mut RuntimeServices = core::ptr::null_mut();
15 15
diff --git a/rsnix/src/vt.rs b/rsnix/src/vt.rs
index 2cfb0f3..709ea71 100644
--- a/rsnix/src/vt.rs
+++ b/rsnix/src/vt.rs
@@ -224,13 +224,7 @@ fn put_byte(b: u8) {
224} 224}
225 225
226fn param(i: usize, default: usize) -> usize { 226fn param(i: usize, default: usize) -> usize {
227 unsafe { 227 unsafe { if i < NPARAMS { PARAMS[i] } else { default } }
228 if i < NPARAMS {
229 PARAMS[i]
230 } else {
231 default
232 }
233 }
234} 228}
235 229
236/// Place a printable glyph at the cursor and advance (wrapping/scrolling). 230/// Place a printable glyph at the cursor and advance (wrapping/scrolling).