Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Sorry, I'm new to os development, and have never programmed using unix assembly, so this may just be a stupid quiestion.
im using c++, and i'm getting a crash exactly on the 0x16 interrupt. I'm not sure if I just set up memory wrong, but I used the virtualbox debugger to confirm that the crash is on that exact instruction. when qemu encounters the crash it restarts, so I can confirm the crash occurs in both when booting the iso with grub, and when booting the kernel with qemu.
here is my code:
How do you boot up? If you're in protected mode -- which I infer from the C code, as most compilers won't output 16-bit code -- then you can't use the BIOS interrupts.
Because i'm in protected mode what would be the best method to get keyboard inputs? I know that you could do virtual 8086 mode, but that sounds complicated, and I don't really understand it.
You typically get keyboard input via just waiting for interrupt 1. At least, that's how you do it on the PIC. I suspect that on the APIC its much harder, but interrupt 1 will give you keyboard data from the PS/2 controller. You'll need somewhere to store it though (I use a ring buffer in my kernel, for example).
Note that interrupt 1 will not just give you keys pressed but keyboard microcontroller information as well. For example, if you send information to the controller (i.e. perform a self test) it willrespond and this interrupt will fire. Check out the PS/2 controller ad PS/2 keyboard articles for more info on this.
0x15 wrote:what would be the best method to get keyboard inputs?
Start with USB drivers. Most keyboards are USB nowadays, and for the ones that aren't, you want your USB drivers to disable USB legacy support anyway. Then, parse the ACPI tables to see if a PS/2 keyboard controller exists, and if it does, start your PS/2 controller driver.
That's a lot of work, though, and you might want to keep things simple for a first attempt. If that's the case, start your simple PS/2 driver by reading a byte from port 0x60 every time you receive IRQ1. (On most computers, this will work even if the keyboard is USB.) You can then work your way up to more complex drivers that properly initialize the hardware as you become more familiar with OS development.