OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 7:53 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Higher Half Kernel not working with Meaty Skeleton
PostPosted: Tue Oct 30, 2018 10:54 am 
Offline

Joined: Fri Oct 26, 2018 12:54 pm
Posts: 20
Hm, this is strange.

When I try to test scrolling with code like this:

Code:
for(int i = 0; i < 25; i++)
    printf("HERE\n");


it does not crash using the standard 'Meaty Skeleton', completely unchanged.

However, when I use 'Meaty Skeleton' with the 'Alternate Higher-Half Kernel' code, and no other changes, it crashes with a SIGSEGV when I try to printf past i = 24.


Top
 Profile  
 
 Post subject: Re: Higher Half Kernel not working with Meaty Skeleton
PostPosted: Tue Oct 30, 2018 7:59 pm 
Online
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 692
I haven't had time to debug this, but I can tell you that at some point you are writing to a memory address outside of the first video page (in my case I noticed an attempt by terminal_putchar to write to physical memory address 0xc03ff000+0x1040). Without paging (0xb8000+0x1040) you can do this because it is okay to write to physical memory addresses between 0xb8000 and 0xc0000. This is video memory. Part of it isn't visible on the screen but you are allowed to write to it. When you enable paging you only map the first 4kb of video memory. 80x25 text mode only takes 2000*2=4000 bytes. That fits inside the one 4096 byte page you have mapped. Once you write beyond that first 4096 bytes it crashes because you are writing to a page that isn't mapped.

This suggests a bug in your screen output routines and I would investigate the real possibility that your scrolling isn't correct.

Effectively paging has identified a bug in your software that always existed.


Top
 Profile  
 
 Post subject: Re: Higher Half Kernel not working with Meaty Skeleton
PostPosted: Wed Oct 31, 2018 9:24 am 
Offline

Joined: Fri Oct 26, 2018 12:54 pm
Posts: 20
MichaelPetch wrote:
I haven't had time to debug this, but I can tell you that at some point you are writing to a memory address outside of the first video page (in my case I noticed an attempt by terminal_putchar to write to physical memory address 0xc03ff000+0x1040). Without paging (0xb8000+0x1040) you can do this because it is okay to write to physical memory addresses between 0xb8000 and 0xc0000. This is video memory. Part of it isn't visible on the screen but you are allowed to write to it. When you enable paging you only map the first 4kb of video memory. 80x25 text mode only takes 2000*2=4000 bytes. That fits inside the one 4096 byte page you have mapped. Once you write beyond that first 4096 bytes it crashes because you are writing to a page that isn't mapped.

This suggests a bug in your screen output routines and I would investigate the real possibility that your scrolling isn't correct.

Effectively paging has identified a bug in your software that always existed.


Thank you for the very informative response. Based on what I have, this means that the provided code on the wiki was not designed to deal with scrolling.

Which is fine; I don't expect you guys to do everything for me, and this difficulty encourages me to become an expert and truly learn.

So, it looks like I will need to better understand paging and also create a "page frame allocator" in order to deal with this scrolling issue.


Top
 Profile  
 
 Post subject: Re: Higher Half Kernel not working with Meaty Skeleton
PostPosted: Wed Oct 31, 2018 9:36 am 
Online
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 692
Bowlslaw wrote:
Thank you for the very informative response. Based on what I have, this means that the provided code on the wiki was not designed to deal with scrolling.


No, this means really that your scrolling is buggy IMHO. The Paging code is fine. When I ran it you were writing beyond the displayable video area. When scrolling you shouldn't have to write anything to the off screen video memory.


Top
 Profile  
 
 Post subject: Re: Higher Half Kernel not working with Meaty Skeleton
PostPosted: Wed Oct 31, 2018 9:50 am 
Offline

Joined: Fri Oct 26, 2018 12:54 pm
Posts: 20
MichaelPetch wrote:
Bowlslaw wrote:
Thank you for the very informative response. Based on what I have, this means that the provided code on the wiki was not designed to deal with scrolling.


No, this means really that your scrolling is buggy IMHO. The Paging code is fine. When I ran it you were writing beyond the displayable video area. When scrolling you shouldn't have to write anything to the off screen video memory.


So, in the kernel code, this loop:

Code:
for(int i = 0; i < 25; i++) {
    printf("HERE\n");
}


I need to make the code handle it once it gets beyond the vga video memory by NOT allowing anything to be written outside of the video memory. Instead, it should take the data and "move" it so that it stays within the vga text buffer.

EDIT: My problem has been solved. I just needed to add bounds checks, which I was unaware I needed because I did not need them when paging not not enabled. I did not understand paging, but I do now, and the code works fine.

Thank you for your help. Lesson learned on my part.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot], MichaelPetch and 168 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group