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

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.
NeonLightions
Member
Member
Posts: 102
Joined: Wed Oct 20, 2021 6:00 pm
Location: Paraguay

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

Post 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
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

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

Post by Octocontrabass »

How did you set up the display for text mode?
NeonLightions
Member
Member
Posts: 102
Joined: Wed Oct 20, 2021 6:00 pm
Location: Paraguay

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

Post by NeonLightions »

I'm set up display at VGA address 0xB8000
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

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

Post by Octocontrabass »

But did you set up text mode? Maybe your bootloader is configuring a linear framebuffer instead.
User avatar
deadmutex
Member
Member
Posts: 85
Joined: Wed Sep 28, 2005 11:00 pm

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

Post by deadmutex »

How are you enabling the cursor? Are you writing to the correct ports?
NeonLightions
Member
Member
Posts: 102
Joined: Wed Oct 20, 2021 6:00 pm
Location: Paraguay

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

Post by NeonLightions »

Yes, I have enabled cursor using port 0x3D4 and 0x3D5
NeonLightions
Member
Member
Posts: 102
Joined: Wed Oct 20, 2021 6:00 pm
Location: Paraguay

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

Post 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
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

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

Post 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?
NeonLightions
Member
Member
Posts: 102
Joined: Wed Oct 20, 2021 6:00 pm
Location: Paraguay

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

Post 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?
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

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

Post 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.
klange
Member
Member
Posts: 679
Joined: Wed Mar 30, 2011 12:31 am
Libera.chat IRC: klange
Discord: klange

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

Post 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.)
NeonLightions
Member
Member
Posts: 102
Joined: Wed Oct 20, 2021 6:00 pm
Location: Paraguay

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

Post 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
klange
Member
Member
Posts: 679
Joined: Wed Mar 30, 2011 12:31 am
Libera.chat IRC: klange
Discord: klange

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

Post 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?
NeonLightions
Member
Member
Posts: 102
Joined: Wed Oct 20, 2021 6:00 pm
Location: Paraguay

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

Post 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?
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

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

Post 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.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Post Reply