-
Notifications
You must be signed in to change notification settings - Fork 63
Fix Release boot by correcting port I/O inline asm constraints #177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
Initial executable segments should be mapped as present, not COW. COW is for fork() where there's an existing backing frame to copy. Initial loads have no previous frame, causing immediate page faults.
Initial process stack should be mapped as present, not COW. COW is for fork() with shared backing. Initial stack has no previous frame.
Don't call scheduler_run() when interrupted from kernel mode. Kernel mode interrupts don't save complete pt_regs frame.
… volatile semantics
- Add __ps2_delay() for busy-wait delays with memory barriers - Add __ps2_blind_read_buffer() for clearing output buffer before writes - Add __ps2_flush_output_buffer() for flushing data with timeout - Refactor ps2_write_data/command to use __ps2_blind_read_buffer - Refactor ps2_initialize to use new helper functions throughout - Eliminates repeated delay loops and buffer flush patterns
- Compiler was eliminating CMOS register reads in Release builds - Replaced read_register() calls with direct inline assembly in rtc_read_datetime() - Added NMI disable, I/O wait cycles, and memory barriers - Improved diagnostics: UIP timeout, all-zero/0xFF reads, mirrored index detection - Added proper I/O wait helper using port 0x80 - RTC now works correctly in both Debug and Release modes
Replaced 7 duplicate inline assembly blocks with calls to __rtc_read_cmos_direct(). Improves code readability while maintaining unoptimizable inline assembly behavior.
- Fixed volatile semantics in paging test loops to prevent optimization - Added proper memory barriers and volatile declarations - Ensured tests work correctly in both Debug and Release builds
…frame - Replaced ISR_NOERR/ISR_ERR macros with single unified ISR macro - Added intelligent privilege level detection (kernel vs user mode) - Normalize stack frame by conditionally pushing SS/UESP in kernel mode - Ensures pt_regs struct alignment matches actual stack layout - Fixes crashes when accessing SS register from kernel exceptions
…rnel exceptions - Removed overly complex stack frame normalization logic - Simplified isr_common to standard register save/restore - Made PRINT_REGS conditional: only access SS/UESP for user mode exceptions - Prevents crashes when exception handlers try to print register state - Exception frame is now simpler and less error-prone
Changed port I/O constraints from 'dN' to 'd' to force dx register usage. The 'dN' constraint allowed compiler to use immediate values in Release mode, but assembly instructions always used %%dx, causing I/O on wrong ports. This fixed years-long issue where OS only booted in Debug mode.
Reverted temporary changes used for debugging: - Removed forced Release compilation for userspace programs and libc - Restored normal CMAKE_BUILD_TYPE optimization flags - Changed log levels back from DEBUG to NOTICE The critical I/O port fix remains in place.
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.
Summary
Root Cause
The I/O port helpers used the
"dN"constraint while the assembly always referenceddx. In Release builds, the compiler could select an immediate instead ofdx, leading to I/O on the wrong ports and device initialization failures.Changes
d(dx) consistently.Impact
Testing