I'm having a little trouble using the 'sti' mnemonic to flip on interrupts. It causes the machine to reboot as soon as it hits that instruction. I'm pretty sure the problem is that I'm calling it from within a 32-bit protected mode app (in NASM).
The bottom line is that I want to simply place a pixel on the screen in the vga-mode of my choosing. So far, the only examples I've found show how to get the video mode setup in 16-bit bootloader code and then once the 32-bit protected mode code is called, IT writes to the video memory. I use GRUB to boot the machine and it immediately launches my little minikernel (successfully), but by that time, I'm already in 32-bit protected mode.
See the problem?
What's the solution?
here's the code:
----------------------------
%define MBOOT_MAGIC 0x1badb002
%define MBOOT_FLAGS 0x00010002
bits 32
org 0x100000
__entry_point:
sti ; THIS IS THE LINE THAT CAUSES THE MACHINE TO REBOOT
mov ah, 0
mov al, 13h
int 10h
mov [0xA0000], byte 5 ; HERE'S WHERE I WOULD DRAW A PIXEL
;
jmp short $
align 4, db 0
header:
dd MBOOT_MAGIC
dd MBOOT_FLAGS
dd 0 - MBOOT_MAGIC - MBOOT_FLAGS
dd header
dd __entry_point
dd end_of_file
dd end_of_file
dd __entry_point
align 4, db 0
end_of_file:
----------------------------
Thanks.
- Philip
interrupts toggling from 32-bit protected mode
RE:interrupts toggling from 32-bit protected mode
When GRUB loads your kernel, the IDT is undefined. Calling STI will _always_ reboot (triple fault) your system until you've defined a proper IDT with all expection handlers defined.
Secondly, unless you write your own entry for 0x13 which mimicks the BIOS, you wont be able to use it... you can't call BIOS interrupts from protected mode!!!
Lastly, if you _do_ decide to create an interface similar to the bios's 0x13, _don't_ install the handler at 0x13. There's a whole load of issues with any interrupt below 0x20 (they're all defined/reserved for exceptions, and I doubt you want your video handler to be called on every GPF).
Cheers,
Jeff
Secondly, unless you write your own entry for 0x13 which mimicks the BIOS, you wont be able to use it... you can't call BIOS interrupts from protected mode!!!
Lastly, if you _do_ decide to create an interface similar to the bios's 0x13, _don't_ install the handler at 0x13. There's a whole load of issues with any interrupt below 0x20 (they're all defined/reserved for exceptions, and I doubt you want your video handler to be called on every GPF).
Cheers,
Jeff