OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 6:31 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Higher Half Kernel not working with Meaty Skeleton
PostPosted: Sat Oct 27, 2018 9:26 am 
Offline

Joined: Fri Oct 26, 2018 12:54 pm
Posts: 20
Hello, I am new to osdev and am running into a problem that I do not understand.

When I use the code from this article: https://wiki.osdev.org/User:Glauxosdeve ... Bare_Bones

I copy it as the kernel., boot.S, and yes, I also change the video memory address to the correct address as defined in the Glauxosdever code.

However, when I try to run ./qemu script, the kernel seems to start up. I see the grub menu and select “myos”. However, it appears to load for around one second and then goes back to the GRUB boot menu.

Are there any known compatibility issues with Higher Half and meaty skeleton?

I can run both higher half and meaty skeleton individually just find.


Top
 Profile  
 
 Post subject: Re: Higher Half Kernel not working with Meaty Skeleton
PostPosted: Sat Oct 27, 2018 9:41 am 
Offline
Member
Member

Joined: Tue Apr 03, 2018 2:44 pm
Posts: 36
You're going to need to provide more information for people to help.

Bowlslaw wrote:
However, when I try to run ./qemu script, the kernel seems to start up. I see the grub menu and select “myos”. However, it appears to load for around one second and then goes back to the GRUB boot menu.


This sounds like a triple fault. You should modify your qemu script and add the following args: -s -no-reboot -no-shutdown. Then you can connect with gdb with "target remote localhost:1234". Add a breakpoint to _start, and start single stepping until something breaks.

_________________
Image is my operating system.

"...not because [it is] easy, but because [it is] hard; because that goal will serve to organize and measure the best of [my] energies and skills..."


Top
 Profile  
 
 Post subject: Re: Higher Half Kernel not working with Meaty Skeleton
PostPosted: Sat Oct 27, 2018 9:49 am 
Offline

Joined: Fri Oct 26, 2018 12:54 pm
Posts: 20
pat wrote:
You're going to need to provide more information for people to help.

Bowlslaw wrote:
However, when I try to run ./qemu script, the kernel seems to start up. I see the grub menu and select “myos”. However, it appears to load for around one second and then goes back to the GRUB boot menu.


This sounds like a triple fault. You should modify your qemu script and add the following args: -s -no-reboot -no-shutdown. Then you can connect with gdb with "target remote localhost:1234". Add a breakpoint to _start, and start single stepping until something breaks.


Thank you! I was not aware that I could do this. I read about the “triple fault” and it, typically, causes the CPU to reset?

Cool debug tip. I will make note of this and try to debug myself.


Top
 Profile  
 
 Post subject: Re: Higher Half Kernel not working with Meaty Skeleton
PostPosted: Sat Oct 27, 2018 9:56 am 
Offline
Member
Member

Joined: Tue Apr 03, 2018 2:44 pm
Posts: 36
Bowlslaw wrote:
Thank you! I was not aware that I could do this. I read about the “triple fault” and it, typically, causes the CPU to reset?


Yeah, basically at that point all hope is lost and the CPU commits sudoku and restarts. You can't recover from it, but you can stop QEMU from restarting to give yourself an opportunity to figure out what's going on.

_________________
Image is my operating system.

"...not because [it is] easy, but because [it is] hard; because that goal will serve to organize and measure the best of [my] energies and skills..."


Top
 Profile  
 
 Post subject: Re: Higher Half Kernel not working with Meaty Skeleton
PostPosted: Sat Oct 27, 2018 1:05 pm 
Offline
Member
Member

Joined: Wed Jun 17, 2015 9:40 am
Posts: 501
Location: Athens, Greece
Hi,


Some time ago, a contributor to that page made some changes in the code, mostly make it easier for a beginner to understand it, use more descriptive symbols and align the code style to the regular Bare Bones. However, he overlooked that "boot_page_table1" was not defined (boot_pagetab1 was defined instead), so you maybe confused it with "boot_page_directory" or something. After these changes, it works for me. I also updated the page accordingly.


Regards,
glauxosdever


Top
 Profile  
 
 Post subject: Re: Higher Half Kernel not working with Meaty Skeleton
PostPosted: Sat Oct 27, 2018 3:49 pm 
Offline

Joined: Fri Oct 26, 2018 12:54 pm
Posts: 20
glauxosdever wrote:
Hi,


Some time ago, a contributor to that page made some changes in the code, mostly make it easier for a beginner to understand it, use more descriptive symbols and align the code style to the regular Bare Bones. However, he overlooked that "boot_page_table1" was not defined (boot_pagetab1 was defined instead), so you maybe confused it with "boot_page_directory" or something. After these changes, it works for me. I also updated the page accordingly.


Regards,
glauxosdever


Thanks. I did notice that issue in the code and changed it just as you did, yesterday, but I am still receiving the same apparent triple fault. I haven't had time to debug as pat mentioned, though.

EDIT: Maybe it's something with my qemu or something.


Top
 Profile  
 
 Post subject: Re: Higher Half Kernel not working with Meaty Skeleton
PostPosted: Sat Oct 27, 2018 6:47 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
It works for me. Do you have a copy of your ISO image available somewhere that I can download and try out? With your ISO I can try out what you have built to see why it may be failing. What is the command(s) inside of your shell scripts that launch QEMU.

Also be curious what Distribution/OS/Version you are using to build the kernel.


Top
 Profile  
 
 Post subject: Re: Higher Half Kernel not working with Meaty Skeleton
PostPosted: Sun Oct 28, 2018 10:54 am 
Offline

Joined: Fri Oct 26, 2018 12:54 pm
Posts: 20
Ok, I figured it out.

After a while, I noticed that the only real difference was how the memory address of the VGA text buffer was set.

In 'Meaty Skeleton', it is like this:

Code:
static uint16_t *const VGA_MEMORY = (uint16_t *)0xC03FF000;

...

terminal_initialize(void) {
    ...
    terminal_buffer = VGA_MEMORY;
    ...
}


This kills the crab, er, OS.

However, I was able to get it to my by simply changing the definition of 'terminal_buffer' to the address itself, without an intermediate varable, like this:

Code:
terminal_buffer = (uint16_t *)0xC03FF000;


The only difference I can see is that the code that works does not have the 'const' modifier. Does anyoen know why this is?

EDIT: AH, I got it. I simply had incorrect syntax for where I placed my '*' operator.

I accidentally made it so the VGA_MEMORY was unchangeable, heh, what a noob error on my part.

I also had code in my kernel which intentionally tried to scroll offscreen so that I could test my scrolling, but, when removed, stopped causing the crash as well.


Top
 Profile  
 
 Post subject: Re: Higher Half Kernel not working with Meaty Skeleton
PostPosted: Sun Oct 28, 2018 11:02 am 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
This sounds like a side effect of some other problem. Have you added some other code (besides the video change) or made other changes that diverge from what is in the tutorial?Are you compiling/assembling/linking the kernel with the same commands as the tutorialor have youdone things differently?


Last edited by MichaelPetch on Sun Oct 28, 2018 11:08 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Higher Half Kernel not working with Meaty Skeleton
PostPosted: Sun Oct 28, 2018 11:07 am 
Offline

Joined: Fri Oct 26, 2018 12:54 pm
Posts: 20
MichaelPetch wrote:
This sounds like aside effect of some other problem. Have you added some other code or made other changes that diverge from what is in the tutorial?


Would changing some of the libc functions, like memcpy, to use pointers, insead of arrays, do it?


Top
 Profile  
 
 Post subject: Re: Higher Half Kernel not working with Meaty Skeleton
PostPosted: Sun Oct 28, 2018 11:13 am 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
Bowlslaw wrote:
Would changing some of the libc functions, like memcpy, to use pointers, insead of arrays, do it?


Could well be a problem if you introduced bugs. It sounds like you have added other code to this project other than what is in the tutorial you linked to. You really should consider putting your whole project on something like github/gitlab or some other service so we can take a look at it. Sounds like the issue may not be the code in the skeleton but something else that has been done beyond that.


Top
 Profile  
 
 Post subject: Re: Higher Half Kernel not working with Meaty Skeleton
PostPosted: Sun Oct 28, 2018 11:25 am 
Offline

Joined: Fri Oct 26, 2018 12:54 pm
Posts: 20
MichaelPetch wrote:
Bowlslaw wrote:
Would changing some of the libc functions, like memcpy, to use pointers, insead of arrays, do it?


Could well be a problem if you introduced bugs. It sounds like you have added other code to this project other than what is in the tutorial you linked to. You really should consider putting your whole project on something like github/gitlab or some other service so we can take a look at it. Sounds like the issue may not be the code in the skeleton but something else that has been done beyond that.


I have changed some. But, I did change it to be a copy of the tutorial. Once I changed the boot.S, linker.ld, and vga address, it works fine, UNTIL I try to scroll offscreen.

https://github.com/Bowlslaw/slawOS/tree/revamp

I have made changes to the 'terminal_putchar(char c)' function in order to test scrolling. The thing that confuses me is that this bug did not exist with meaty skeleton's default tutorial code. It only started crashing once I added the alternate higher half code.


Top
 Profile  
 
 Post subject: Re: Higher Half Kernel not working with Meaty Skeleton
PostPosted: Mon Oct 29, 2018 1:58 pm 
Offline

Joined: Fri Oct 26, 2018 12:54 pm
Posts: 20
Ok, I hooked up the kernel to GDB like this:

Code:
./build.sh
qemu-system-i386 -cdrom myos.iso -s -no-reboot -no-shutdown
gdb sysroot/boot/myos.kernel
gdb> target remote localhost:1234


I then 's' through the code, until I reach these values:

Code:
0xc0100179 <_start+36>  mov    %edx,(%edi)


Where it proceeds to crash with SIGSEGV. It seems like it crashes the moment it hits _start.

I'm just trying test scrolling, and so the changes I made to tty.c are on lines 48 and 62 in the repo.


Top
 Profile  
 
 Post subject: Re: Higher Half Kernel not working with Meaty Skeleton
PostPosted: Mon Oct 29, 2018 2:31 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
My apologies, I misread one of your updates and I thought you got it working somehow. Is Github updated with what you are now testing?


Top
 Profile  
 
 Post subject: Re: Higher Half Kernel not working with Meaty Skeleton
PostPosted: Mon Oct 29, 2018 2:52 pm 
Offline

Joined: Fri Oct 26, 2018 12:54 pm
Posts: 20
MichaelPetch wrote:
My apologies, I misread one of your updates and I thought you got it working somehow. Is Github updated with what you are now testing?


Yes, but at this moment I think I figured it out. In the repo I linked, look at (https://github.com/Bowlslaw/slawOS/blob ... /tty.c#L62), line 62-72. I removed this, and the problem vanished, even when I get the for loop in kernel.c to way beyond the VGA_WIDTH/HEIGHT.

I was getting a SIGSEGV, so...I think I was trying to write colors to areas outside of the VGA buffer?


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], DotBot [Bot] and 65 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