console: share the Uart by reference and add iprint - #5
Closed
gmacd wants to merge 7 commits into
Closed
Conversation
Signed-off-by: Graham MacDonald <grahamamacdonald@gmail.com>
Signed-off-by: Graham MacDonald <grahamamacdonald@gmail.com>
Signed-off-by: Graham MacDonald <grahamamacdonald@gmail.com>
req_buffer_va/req_buffer_pa held VirtRange/PhysRange values; name them req_buf_virtrange/req_buf_physrange like the rest of the file. Also drop an unused pub on mbox_virtrange.
Add port::irq with an RAII IrqGuard (mask IRQs on new, restore the previous state on drop; nestable; no-op until an arch registers its mask/restore hooks) and an interrupt-depth counter (enter_interrupt/ exit_interrupt/in_interrupt) so subsystems can either mask around locks shared with interrupt context or assert they are never used from it. aarch64 registers a DAIF-based implementation at early boot and brackets the trap handler with the depth counter. Other arches are unaffected: the guard is a no-op and in_interrupt is always false until they opt in.
The console Uart is now held as &'static dyn Uart rather than &mut: putb only needs a shared reference, and a shared reference lets the same Uart be aliased by the new direct-print path. Add iprint/iprintln in the tradition of Plan 9's iprint: mask IRQs, take only a best-effort bounded-spin interlock, and write polled bytes straight to the hardware, bypassing the console lock. This is the print for interrupt context, panic, and console/lock debugging; each arch registers a direct byte writer at console init. The console lock itself becomes thread-context-only, enforced with a debug assertion, so println no longer needs to mask IRQs around UART output. The aarch64 panic handler and trap handler switch to iprintln accordingly.
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.
The console Uart is now
&'static dyn Uartrather than&mut—putbonly needs a shared reference, and sharing lets the same Uart be aliased by the new direct-print path.Adds
iprint/iprintlnin the tradition of Plan 9's iprint: masks IRQs, takes only a best-effort bounded-spin interlock, and writes polled bytes straight to the hardware, bypassing the console lock. This is the print for interrupt context, panic, and console/lock debugging. The console lock becomes thread-context-only (debug-asserted), soprintlnno longer masks IRQs around UART output. The aarch64 panic and trap handlers switch toiprintln.Stacked on #4; review the last commit.