I've seen a post before yours on this issue, which also involved booting from GRUB. Apparently, some GRUB builds don't make the cursor visible on QEMU, and since there is no BIOS functions for you, you need to configure the VGA registers yourself.
Code: Select all
outb(0x3D4, 0x09); // set maximum scan line register to 15
outb(0x3D5, 0x0F);
outb(0x3D4, 0x0B); // set the cursor end line to 15
outb(0x3D5, 0x0F);
outb(0x3D4, 0x0A); // set the cursor start line to 14 and enable cursor visibility
outb(0x3D5, 0x0E);
In case you don't want to copy/paste without knowing what you're doing, the first two lines write the value 15 to register index 9, which is the "maximum scan line" register. This register encodes the height of each character on the VGA text mode screen minus 1. In your case, the default for VGA mode 3 (which is the default VGA text mode) the height is 16, and so we write 15. The next access write the value 15 to register index 11, which is the "cursor end line" register. From the hardware's point of view, the cursor is simply a rectangle whose width is always the character's width, but height can be configured. The cursor end line encodes the last Y coordinate of the cursor, which is 15 because the character's height is 16. The next access writes the value 14 to register index 10, which sets the first Y coordinate of the cursor, which is 14. Ultimately, this tells the hardware to draw a cursor from Y coordinate 14 to Y coordinate 15, which makes a rectangle with height 1 pixel, which really is an underscore cursor. Play around and try the different cursor sizes you can make.