OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 21, 2019 4:45 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Printing ticks doesn't work
PostPosted: Sat Feb 02, 2019 6:55 am 
Offline

Joined: Sun May 29, 2016 11:23 am
Posts: 10
Location: Poland
Hello,

https://github.com/jpacanowski/GekonOS/blob/master/kernel/timer.c#L12

I want to print out the ticks on the screen and I don't know why this kprintf() function doesn't work...
It looks like something crashed.

It's been 2 weeks I've been trying to figure it out...

Could you help me, please?

Best regards

_________________
https://github.com/jpacanowski/
http://jpacanowski.pl/


Top
 Profile  
 
 Post subject: Re: Printing ticks doesn't work
PostPosted: Sat Feb 02, 2019 7:51 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 1487
It looks like you're following James Molloy's tutorial, which is known to have bugs. Here's a list of the bugs we know about. (This list may not be complete.)

In particular, take a look at the section titled "Interrupt handlers corrupt interrupted state". That's usually the first one people run into.


Top
 Profile  
 
 Post subject: Re: Printing ticks doesn't work
PostPosted: Sat Feb 02, 2019 10:17 am 
Offline

Joined: Sun May 29, 2016 11:23 am
Posts: 10
Location: Poland
Thanks for the reply.

I modified the interrupt.asm file according to the "James Molloy's Tutorial Known Bugs", but still the same... ;(

The rest of my code looks like it's OK.. Especially when I compare my code to this one:
https://github.com/cfenollosa/os-tutorial

Somebody, help me please...

I want to start further OS development, but I'm stuck with it...
It's been 2 weeks... ;(

_________________
https://github.com/jpacanowski/
http://jpacanowski.pl/


Top
 Profile  
 
 Post subject: Re: Printing ticks doesn't work
PostPosted: Sat Feb 02, 2019 10:25 am 
Offline
Member
Member
User avatar

Joined: Mon Sep 03, 2018 2:25 am
Posts: 37
Your call to
Code:
void register_interrupt_handler(u8 n, isr_t handler)
in timer.c shouln't do &timer_callback but just timer_callback since functions are all already pointers, and timer_callback should have registers_t in its arguments. Also you should do 23-fixes from https://github.com/cfenollosa/os-tutorial


Top
 Profile  
 
 Post subject: Re: Printing ticks doesn't work
PostPosted: Sat Feb 02, 2019 12:50 pm 
Offline

Joined: Sun May 29, 2016 11:23 am
Posts: 10
Location: Poland
I have done all the fixes according to the 23-fixes and your advice, but it still doesn't work...
I fixed interrupt.asm, created mem* functions, changed registers_t r into registers_t *t, and so on...

_________________
https://github.com/jpacanowski/
http://jpacanowski.pl/


Top
 Profile  
 
 Post subject: Re: Printing ticks doesn't work
PostPosted: Sat Feb 02, 2019 1:07 pm 
Offline
Member
Member
User avatar

Joined: Mon Sep 03, 2018 2:25 am
Posts: 37
I've just cloned your repo and it seems to be working for me, so the one thing I could think about is compile eviroment changes. You should compile with a cross-compiler GCC_Cross-Compiler

edit: Here's a link to my compiled ISO https://mega.nz/#!lLhlFKKD!j_dt023QdXBT ... pKT93b02YI


Top
 Profile  
 
 Post subject: Re: Printing ticks doesn't work
PostPosted: Sat Feb 02, 2019 7:57 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 376
thomtl is making a good suggesting about making a cross compiler rather than use you the native compiler on your OS. The problem is in how you are building and linking your code. The issue is that your native compiler is defaulting to position independent code and position independent executable code generation. You are hiding the problem(not fixing it) by adding --ignore-unresolved-symbol _GLOBAL_OFFSET_TABLE_ to your linking command. Remove this from the linking step, and add the `-fno-PIE` option instead. You will also have to compile the .c files without position independent code as well so you'll need to add the `-fno-PIC` flag to the C flags you are using. The changedlines in your build file could look like:
Code:
# default variables
CFLAGS="-m32 -c -g -O2 -W -Wall -Wextra -Werror -fno-PIC "\
"-ffreestanding -std=gnu99 -fno-builtin -Ikernel/include -Ilibc/include"

CFLAGS_LIBC="-m32 -c -g -O2 -W -Wall -Wextra -Werror -fno-PIC "\
"-ffreestanding -std=gnu99 -fno-builtin -Ikernel/include -Ilibc/include"
then:
Code:
ld -g -m elf_i386 -T kernel/link.ld -no-PIE -o kernel.bin kentry.o kernel.o video.o gdt.o idt.o isr.o timer.o x86.o interrupt.o vbe.o gui.o libc.a
I am curious where you might have learned to use --ignore-unresolved-symbol _GLOBAL_OFFSET_TABLE_? Someone else in the past few weeks had the same problem in a question on this forum.


Top
 Profile  
 
 Post subject: Re: Printing ticks doesn't work
PostPosted: Wed Feb 06, 2019 10:13 am 
Offline

Joined: Sun May 29, 2016 11:23 am
Posts: 10
Location: Poland
Thanks! Building own cross-compiler really helped. Now everything is working well...

But compiling big projects (like GCC) is what I really hate doing by myself... Why? Lots of code and lots of warning when compiling... My heart is beating faster when I type "make all". That's why I stayed away from compiling my own cross-compiler... It all happened for the first time when I wanted to compile the Linux kernel from sources... ;)

I will also do what MichaelPetch wrote by fixing how I am linking the code by adding --ignore-unresolved-symbol _GLOBAL_OFFSET_TABLE_
Where did I find that? Well, on Stack overflow ;)

Thank you, guys...

_________________
https://github.com/jpacanowski/
http://jpacanowski.pl/


Top
 Profile  
 
 Post subject: Re: Printing ticks doesn't work
PostPosted: Wed Feb 06, 2019 10:59 am 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 376
In the context of making shared libraries it can make sense, but not here. Can you post a link to the StackOverflow post?


Top
 Profile  
 
 Post subject: Re: Printing ticks doesn't work
PostPosted: Thu Feb 07, 2019 2:34 pm 
Offline

Joined: Sun May 29, 2016 11:23 am
Posts: 10
Location: Poland
I'm sorry, it was not Stack Overflow...
https://github.com/cfenollosa/os-tutorial/issues/16

_________________
https://github.com/jpacanowski/
http://jpacanowski.pl/


Top
 Profile  
 
 Post subject: Re: Printing ticks doesn't work
PostPosted: Fri Feb 08, 2019 12:14 am 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 376
Thanks, I had a suspicion it was that. Last week I posted a warning there not to use it in that way.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 9 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