p13-dev-fs Device Virtual Filesystem Integration#23
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
p13-dev-fs Device Virtual Filesystem
Branch: p13-dev-fs
Type: Original implementation
Impact: Enables device-as-file abstraction with console I/O through file operations
Context:
Implemented device virtual filesystem allowing devices to be accessed through standard file operations (open/read/write). Built on p12-log (PR #22 ). Follows C implementation semantics from
p13-dev-fs.mdspecification.Changes Made:
Device Constants (
src/param.rs)NDEV = 10(maximum device numbers)CONSOLE = 1(console device major number)Device Switch Table (
src/file.rs)Devswstruct with function pointer fields:static mut DEVSW: [Devsw; NDEV]global device tableFileType::Devicevariant to enum (was onlyNone,Inode)mknod(path, major, minor)function:begin_op()/end_op()transactionscreate()withT_DEVtype and device numbersConsole Device Handlers (
src/console.rs)consoleread(ip, dst, n) -> i32:INPUTbuffer circular queue (r/w/eindices)consolewrite(ip, src, n) -> i32:consputc()consoleinit():consoleread/consolewriteinDEVSW[CONSOLE]Device I/O Routing (
src/fs.rs)readi()to check forT_DEVtype (early return before offset validation):writei()with identical pattern for device write dispatchT_DEV,NDEV,DEVSWBoot Initialization (
src/lib.rs)console::consoleinit()afterioapic_init()(registers handlers)file::mknod("/console", CONSOLE, CONSOLE)afterinitlog()(creates device file)welcome()function to test console device:Critical Bug/Implementation Fixes
Compiler Optimization Blocking
consoleread()hung indefinitely in spin loop despite interrupt handler updatingINPUT.wINPUT.randINPUT.wvalues (tight loop with no modifications visible to optimizer)wupdating from 0 to 6, but read loop never observed changecore::ptr::read_volatile()to force re-reading on every iteration:Byte Count Mismatch
n=6for 5-byte string (reading garbage byte)n=5or use.len() as i32Constraints Met:
fs.rsmatches C placement (before offset checks)mknod()matches C patternTesting:
/consolein root directory)welcome()prompts for name input