Page 1 of 2

Err... Text cursor doesn't appear in long mode?

Posted: Wed Oct 20, 2021 6:05 pm
by NeonLightions
This is akward, since I'm programming a kernel in long mode. Everything is fine except there is no text cursor in the screen. I have tried all methods on Internet such as OsDev wiki and Jose's wiki, even Jame's kernel development tutorial. But all of them did not bring positive results. It's still just a blank black screen. Can anybody help me solve this issue? Reply me if you want to see the source code. Thank you very much for reading my question.

Sorry for my bad English

Re: Err... Text cursor doesn't appear in long mode?

Posted: Wed Oct 20, 2021 7:33 pm
by Octocontrabass
How did you set up the display for text mode?

Re: Err... Text cursor doesn't appear in long mode?

Posted: Wed Oct 20, 2021 7:44 pm
by NeonLightions
I'm set up display at VGA address 0xB8000

Re: Err... Text cursor doesn't appear in long mode?

Posted: Wed Oct 20, 2021 9:06 pm
by Octocontrabass
But did you set up text mode? Maybe your bootloader is configuring a linear framebuffer instead.

Re: Err... Text cursor doesn't appear in long mode?

Posted: Wed Oct 20, 2021 9:18 pm
by deadmutex
How are you enabling the cursor? Are you writing to the correct ports?

Re: Err... Text cursor doesn't appear in long mode?

Posted: Wed Oct 20, 2021 9:20 pm
by NeonLightions
Yes, I have enabled cursor using port 0x3D4 and 0x3D5

Re: Err... Text cursor doesn't appear in long mode?

Posted: Wed Oct 20, 2021 9:23 pm
by NeonLightions
Reply to Octocontrabass

I think the bootloader is working correctly. It isn't use any linear framebuffer. Everything is working correctly except the text cursor

Re: Err... Text cursor doesn't appear in long mode?

Posted: Wed Oct 20, 2021 9:38 pm
by Octocontrabass
NeonLightions wrote:Yes, I have enabled cursor using port 0x3D4 and 0x3D5
What values did you write to those ports?
NeonLightions wrote:I think the bootloader is working correctly. It isn't use any linear framebuffer.
Which bootloader are you using?

Re: Err... Text cursor doesn't appear in long mode?

Posted: Wed Oct 20, 2021 9:43 pm
by NeonLightions
Octocontrabass wrote:
NeonLightions wrote:Yes, I have enabled cursor using port 0x3D4 and 0x3D5
What values did you write to those ports?

Here is my code:

Code: Select all

void enable_cursor(uint8_t size)
{
    uint8_t start_line = 16 - size;
	outb(0x3D4, 0x0A);
	outb(0x3D5, (inb(0x3D5) & 0xC0) | start_line);
 
	outb(0x3D4, 0x0B);
	outb(0x3D5, (inb(0x3D5) & 0xE0) | 15);
}

void update_cursor(int x, int y)
{
	uint16_t pos = y * 80 + x;
 
	outb(0x3D4, 0x0F);
	outb(0x3D5, (uint8_t) (pos & 0xFF));
	outb(0x3D4, 0x0E);
	outb(0x3D5, (uint8_t) ((pos >> 8) & 0xFF));
}

void move_cursor(void) {
    const size_t idx = y_pos * 80 + x_pos;
    outb(0x3D4, 0x0F);
    outb(0x3D5, (uint8_t) (idx & 0xFF));
    outb(0x3D4, 0x0E);
    outb(0x3D5, (uint8_t) ((idx >> 8) & 0xFF));
}
NeonLightions wrote:I think the bootloader is working correctly. It isn't use any linear framebuffer.
Which bootloader are you using?
I'm using GRUB. Is there any linear framebuffer? After all, I'm just a newbie with this project. Forgive me if there any mistake in my words and my lack knowledge post

If there is linear framebuffer, can you show me how to enable text cursor in it?

Re: Err... Text cursor doesn't appear in long mode?

Posted: Wed Oct 20, 2021 10:20 pm
by Octocontrabass
NeonLightions wrote:Here is my code:
How are you calling enable_cursor? Are you sure outb works?
NeonLightions wrote:I'm using GRUB. Is there any linear framebuffer?
Are you using BIOS/CSM or UEFI? GRUB with UEFI will always set up a linear framebuffer.

How did you configure GRUB and your multiboot header? If you told it you want a linear framebuffer, it will give you a linear framebuffer.
NeonLightions wrote:If there is linear framebuffer, can you show me how to enable text cursor in it?
There's no such thing as a text cursor in a linear framebuffer.

Re: Err... Text cursor doesn't appear in long mode?

Posted: Wed Oct 20, 2021 11:18 pm
by klange
Octocontrabass wrote:How did you configure GRUB and your multiboot header? If you told it you want a linear framebuffer, it will give you a linear framebuffer.
(You can override this by setting gfxpayload to "text" (of course, only under BIOS) after loading your kernel.)

Re: Err... Text cursor doesn't appear in long mode?

Posted: Thu Oct 21, 2021 12:59 am
by NeonLightions
Octocontrabass wrote:How are you calling enable_cursor? Are you sure outb works?
I haved called enable_cursor() at the start of kernel_main and I'm sure outb work 100% perfectly

Octocontrabass wrote:Are you using BIOS/CSM or UEFI? GRUB with UEFI will always set up a linear framebuffer.
I'm using BIOS
Octocontrabass wrote:How did you configure GRUB and your multiboot header? If you told it you want a linear framebuffer, it will give you a linear framebuffer.
Like I said, I'm just a newbie. So I'm just set default to it

Octocontrabass wrote:There's no such thing as a text cursor in a linear framebuffer.
I will keep this in mind

Re: Err... Text cursor doesn't appear in long mode?

Posted: Thu Oct 21, 2021 1:17 am
by klange
It would be helpful to see the rest of your source tree, if you can provide it.

I think an important question that hasn't been asked yet is have you outputted any text yet?

Re: Err... Text cursor doesn't appear in long mode?

Posted: Thu Oct 21, 2021 1:30 am
by NeonLightions
klange wrote:It would be helpful to see the rest of your source tree, if you can provide it.
Here is my source tree:

Code: Select all

[MyOS]
|__ [scripts]
|    |__ .gitignore
|    |__ grub.cfg
|    |__ linker.ld
|__ [src]
|    |__ [boot]
|    |    |__ header.s
|    |    |__ main.s
|    |    |__ main64.s
|    |__ [common]
|    |    |__ printf.c
|    |    |__ printf.h
|    |    |__ types.h
|    |__ [display]
|    |    |__ vga.c
|    |    |__ vga.h
|    |    |__ terminal.h
|    |    |__ terminal.c
|    |__ [device]
|    |    |__ port.c
|    |    |__ port.h
|    |__ [interrupts]
|    |    |__ idt.c
|    |    |__ idt.h
|    |    |__ load_idt.s
|    |    |__ isr.c
|    |    |__ isr.h
|    |__ [memory]
|    |    |__ gdt.c
|    |    |__ gdt.h
|    |    |__ load_gdt.s
|    |__ main.c
|__ Makefile
klange wrote:I think an important question that hasn't been asked yet is have you outputted any text yet?
I'm sorry but what is that?

Re: Err... Text cursor doesn't appear in long mode?

Posted: Thu Oct 21, 2021 1:42 am
by neon
Hi,

You mentioned that all you see is a blank screen. Are you able to display any text at all? I.e. implement a quick function to print a string to 0xb8000 and verify if it works or not.