Hardware Interrupts #1003
Replies: 78 comments 36 replies
-
Hi, I'd be interested in writing the small scancode_set1 crate! You can reach me at trinioler at gmail.com if you want to continue the discussion out of band. :) |
Beta Was this translation helpful? Give feedback.
-
@ZerothLaw Awesome, I'll write you an email! |
Beta Was this translation helpful? Give feedback.
-
I’m following your tutorials, and (am currently) creating an API for device drivers. Thanks for the amazing work! |
Beta Was this translation helpful? Give feedback.
-
@rybot666 You're welcome! What are your plans for the API design? |
Beta Was this translation helpful? Give feedback.
-
I'm curious if you have any plans for how to do APIC, as it doesn't look like there is a crate for it. |
Beta Was this translation helpful? Give feedback.
-
@phil-opp I’m planning on using traits to implement it (I’ve got a EDIT: Forgot the link |
Beta Was this translation helpful? Give feedback.
-
I wrote a crate called pc-keyboard which handles raw access to a UK 105 key PS/2 keyboard generating scan code set 2. Happy for patches to make it work with set 1 and other keyboard layouts. |
Beta Was this translation helpful? Give feedback.
-
@thejpster Awesome! cc @ZerothLaw |
Beta Was this translation helpful? Give feedback.
-
@rybot666 Ah, so that devices can register and unregister for certain interrupts at runtime? |
Beta Was this translation helpful? Give feedback.
-
@donald-pinckney Nothing specific yet, just some vague ideas. |
Beta Was this translation helpful? Give feedback.
-
@phil-opp Exactly. Currently (as in right now) trying to get rid of errors about not being able to send Fn(...) types across threads |
Beta Was this translation helpful? Give feedback.
-
@rybot666 I think you need to add the |
Beta Was this translation helpful? Give feedback.
-
@phil-opp Yea, I have and it seems to have fixed that. Although my current device isn't very good (an iPad and the Github editor). |
Beta Was this translation helpful? Give feedback.
-
Hey @thejpster I'll see about sending you a PR with scancode set 1 sometime soon. |
Beta Was this translation helpful? Give feedback.
-
"As already mentioned, the 8259 APIC has been superseded by the APIC" Perhaps "8259 PIC" was intended here? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Another bizarre thing I forgot to mention in the above comment is that the instruction pointer that triggers the fault keeps changing every time I make changes to the code for debugging reasons. Even more of a reason to suspect that the x86_64 crate is attempting to overwrite Index 16 in the error code selector table. |
Beta Was this translation helpful? Give feedback.
-
Another weird behavior: the fact that if my general protection fault handler doesn’t halt the CPU, an endless stream of general protection faults appears — even if a call to The only difference between my timer Interrupt handler and the timer Interrupt handler in this example is that it calls |
Beta Was this translation helpful? Give feedback.
-
If you want to implement your own PS/2 keyboard controller, here you can find all the scancodes https://www.kbdlayout.info/ |
Beta Was this translation helpful? Give feedback.
-
@kennystrawnmusic - I am getting the same GPF as you. From my investigation so far it appears to he happening on the "iretq" instruction of any hardware interrupt. I've tested this by masking off all but the timer interrupt, setting a breakpoint on this handler in gdb and single-stepping the code. This confirms that the GPF occurs immediately upon the "iretq" instruction. This happens even with an empty handler and with the keyboard interrupt if I mask off all other interrupts. So I'm pretty sure the cause is the return instruction. in any hardware interrupt handler. (Probably with exception handlers too, but they never return - I might try creating a non-panicking exception handler to test this.) But I can't figure out why! The error code (16) is valid - it indicates that the problem is with segment selector 0x10. But the qemu monitor shows this as being valid in all respects, as far as I can see. I suspect that the error is related to the stack, but I'm still trying to figure it out. I'll let you know if I have any success. |
Beta Was this translation helpful? Give feedback.
-
Got it! You need to add a kernel_data_selector in gdt.rs lazy_static! { struct Selectors { It seems that, otherwise, the tss_segment_selector and data (and hence stack) selectors are the same, which causes the problem. |
Beta Was this translation helpful? Give feedback.
-
Here’s the code from my get.rs file, which works for me:
…---------------------------------------------------------------------------------------------------------------------
pub fn init() {
use x86_64::instructions::tables::load_tss;
use x86_64::registers::segmentation::{Segment, CS, DS};
GDT.0.load();
unsafe {
CS::set_reg(GDT.1.code_selector);
DS::set_reg(GDT.1.data_selector);
load_tss(GDT.1.tss_selector);
}
}
use x86_64::structures::gdt::{Descriptor, GlobalDescriptorTable, SegmentSelector};
lazy_static! {
static ref GDT: (GlobalDescriptorTable, Selectors) = {
let mut gdt = GlobalDescriptorTable::new();
let code_selector = gdt.add_entry(Descriptor::kernel_code_segment());
let data_selector = gdt.add_entry(Descriptor::kernel_data_segment());
let tss_selector = gdt.add_entry(Descriptor::tss_segment(&TSS));
let user_data_selector = gdt.add_entry(Descriptor::user_data_segment());
let user_code_selector = gdt.add_entry(Descriptor::user_code_segment());
(
gdt,
Selectors {
code_selector,
data_selector,
tss_selector,
_user_data_selector: user_data_selector,
_user_code_selector: user_code_selector,
},
)
};
}
struct Selectors {
code_selector: SegmentSelector,
data_selector: SegmentSelector,
tss_selector: SegmentSelector,
_user_data_selector: SegmentSelector,
_user_code_selector: SegmentSelector,
}
-----------------------------------------------------------------------------------------------------------
On 30 Mar 2022, at 21:07, Kenny Strawn ***@***.***> wrote:
The selector of the not-present error I get this time is 59, just for reference. Might be looking for some non-existent driver of some kind; not entirely sure though.
—
Reply to this email directly, view it on GitHub <#1003 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAMYX4RE2TSY6HIP75J7FULVCSYB3ANCNFSM5DBWJIQA>.
You are receiving this because you commented.
|
Beta Was this translation helpful? Give feedback.
-
Alright, so in summary, here's how I was able to get the APIC timer working properly, for those of you guys who are also looking to do likewise:
A lot of work to say the least but it was definitely worth it. |
Beta Was this translation helpful? Give feedback.
-
Excellent writeup @phil-opp! I wonder how one would change the settings of the timer? Is this memory mapped somewhere to be accessible? |
Beta Was this translation helpful? Give feedback.
-
Had to restart development from scratch due to failure of the USB flash drive that I had all my code backed up to and now, when trying to get the APICs set up and doing everything I did before (including using the heap allocator function to properly memory-map both the LAPIC and the IOAPIC) I'm getting a panic with this message:
Since interrupt handlers are defined in the |
Beta Was this translation helpful? Give feedback.
-
Kenny,
I’m glad that solved your immediate problem. I’m afraid that I haven’t looked into the UEFI version as yet, so I can’t really help with that problem. It’s on my “to do” list, but I’m working on a disk driver, and then file system, at the moment.
If I get time to look at the UEFI version, and can throw any light on that problem, I’ll let you know.
Ian
… On 7 Mar 2022, at 22:29, Kenny Strawn ***@***.***> wrote:
Thanks, that did solve the issue with the legacy (BIOS) version. The UEFI version, however, is still faulting twice: first with a segment-not-present and then with a divide error (presumably the result of attempting to perform a division-type operation on a segment that doesn't exist). What segment is it looking for? I've got the CS, DS, and TSS loaded; what else needs to be present for the UEFI version to work?
—
Reply to this email directly, view it on GitHub <#1003 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAMYX4Q2OLS66MXOVM7BTADU6Z7OFANCNFSM5DBWJIQA>.
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.
|
Beta Was this translation helpful? Give feedback.
-
@phil-opp any illustration on the way for APIC support? PIC does not work with UEFI. Or could you point me to an existing illustration of APIC for the bootloader/bootloader_api? |
Beta Was this translation helpful? Give feedback.
-
I encountered an issue where the port used to listen to keyevents doesn't emit any events for the command key on macs. If anyone has any idea how to fix this then please tell me, Im genuinely confused to what it could be. I thought it could maybe be that qemu doesn't map the command key to the vm but I wouldn't know how to change that either :/ |
Beta Was this translation helpful? Give feedback.
-
Hi everyone :-) I was wondering: would using |
Beta Was this translation helpful? Give feedback.
-
error[E0433]: failed to resolve: could not find error[E0433]: failed to resolve: could not find why could not find |
Beta Was this translation helpful? Give feedback.
-
This is a general purpose comment thread for the “Hardware Interrupts” post.
Beta Was this translation helpful? Give feedback.
All reactions