Skip to content

Commit 3db8aa1

Browse files
committed
Optimize clearing framebuffer
1 parent b7af914 commit 3db8aa1

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,10 @@ make test
106106

107107
## TODO
108108

109-
- framebuffer crate removal
110-
- Fix page fault caused by `write-framebuffer hello` (I think page table changes broke this)
109+
- Fix page fault caused by `write-framebuffer hello` (I think page table changes broke this)
110+
- It is just when `framebuffer.clear();` is called. When that is commented out stuff works fine.
111+
- The address of the page fault changes. It this caused by some kind of interrupt during the clear?
112+
- Are interrupts + task switches broken in kernel code? I would expect the prime number thing to break if so. Maybe just the shell for some reason?
111113
- VFS read/write code:
112114
- Change inode `write` API to be similar to read (based on blocks)
113115
- Nuke old block iteration code in ext2 now that write and read don't need it

kernel/src/graphics/framebuffer.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,17 +139,11 @@ impl VESAFramebuffer32Bit {
139139
}
140140

141141
pub(super) fn clear(&mut self) {
142-
// for i in 0..(self.pitch * self.height_pixels) {
143-
// unsafe {
144-
// *self.address.add(i) = 0x00;
145-
// }
146-
// }
147-
148-
// This is faster in debug mode, and it is neat, so I'm keeping it
149-
// around.
150142
unsafe {
151-
core::slice::from_raw_parts_mut(self.address, self.pitch * self.height_pixels)
152-
.fill(0x00);
143+
// N.B. `write_bytes` is a highly optimized way to write zeroes.
144+
// Making a slice and doing `slice.fill(0)` is supposed to optimize
145+
// to this, but it doesn't seem to when compiling in debug mode.
146+
self.address.write_bytes(0, self.pitch * self.height_pixels);
153147
};
154148
}
155149
}

0 commit comments

Comments
 (0)