OSDev.org
https://forum.osdev.org/

Printing ticks doesn't work
https://forum.osdev.org/viewtopic.php?f=1&t=33476
Page 1 of 1

Author:  jpacanowski [ Sat Feb 02, 2019 6:55 am ]
Post subject:  Printing ticks doesn't work

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

Author:  Octocontrabass [ Sat Feb 02, 2019 7:51 am ]
Post subject:  Re: Printing ticks doesn't work

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.

Author:  jpacanowski [ Sat Feb 02, 2019 10:17 am ]
Post subject:  Re: Printing ticks doesn't work

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... ;(

Author:  thomtl [ Sat Feb 02, 2019 10:25 am ]
Post subject:  Re: Printing ticks doesn't work

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

Author:  jpacanowski [ Sat Feb 02, 2019 12:50 pm ]
Post subject:  Re: Printing ticks doesn't work

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...

Author:  thomtl [ Sat Feb 02, 2019 1:07 pm ]
Post subject:  Re: Printing ticks doesn't work

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

Author:  MichaelPetch [ Sat Feb 02, 2019 7:57 pm ]
Post subject:  Re: Printing ticks doesn't work

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.

Author:  jpacanowski [ Wed Feb 06, 2019 10:13 am ]
Post subject:  Re: Printing ticks doesn't work

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...

Author:  MichaelPetch [ Wed Feb 06, 2019 10:59 am ]
Post subject:  Re: Printing ticks doesn't work

In the context of making shared libraries it can make sense, but not here. Can you post a link to the StackOverflow post?

Author:  jpacanowski [ Thu Feb 07, 2019 2:34 pm ]
Post subject:  Re: Printing ticks doesn't work

I'm sorry, it was not Stack Overflow...
https://github.com/cfenollosa/os-tutorial/issues/16

Author:  MichaelPetch [ Fri Feb 08, 2019 12:14 am ]
Post subject:  Re: Printing ticks doesn't work

Thanks, I had a suspicion it was that. Last week I posted a warning there not to use it in that way.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/