Page 1 of 1

PIT and Kernel Problems

Posted: Sun Sep 21, 2008 8:23 am
by System123
Hi

I have two problems at the moment.Problem 1 is the my Sleep function in my Timer(PIT) does not work. It gets stuck in a continuous loop.

Here is the code

Code: Select all

procedure TimerHandler(var Reg : TRegisters);
begin
Inc(TimerTicks); 
end;

procedure Sleep(Ticks : LongWord);
var
  ETicks: LongWord;
begin
  ETicks := TimerTicks + Ticks;
  while TimerTicks < ETicks do;
end;
The other problem is that I my kernel is at a stage where its size is 68Kb, however the problem is now my 2nd stage loader won't load the kernel properly. It just jumps to some code that is not mine! What is the problem? I know it is the 2nd stage loader because if my kernel has any code taken out ie:Beep procedure. It is less than 68Kb and then it loads and runs. Attached is my 2nd stage loader code.
2ndStage.rar
(9.2 KiB) Downloaded 27 times
Thanks in advance

Re: PIT and Kernel Problems

Posted: Sun Sep 21, 2008 8:57 am
by Laksen
Do you remember to ack the PIC?

Re: PIT and Kernel Problems

Posted: Sun Sep 21, 2008 9:31 am
by Troy Martin
...That looks like neon's second stage bootloader...

I assume that the loader has some issues with loading ANYTHING over 64 KB, but I can't scope it out. Sorry.

Re: PIT and Kernel Problems

Posted: Sun Sep 21, 2008 12:54 pm
by System123
I got the second stage loader from Brans Kernel Tutorials I think. It was from some tutorial. I just made slight changes to it because I needed a 2nd stage loader to continue. I will eventually write my own.

OK I figured out the PIT Sleep problem :oops: really stupid of me. I called the Sleep function in of the other units before I had run the STI command. So it all works fine now. Its just that 2nd stage loader

Re: PIT and Kernel Problems

Posted: Sun Sep 21, 2008 3:30 pm
by Troy Martin
I just remember PIT needs STI. Sort of like the old batch file rule, SHIFT needs IF.

And yeah, that's the Brokenthorn tutorial second stage. I use the same one :)

Re: PIT and Kernel Problems

Posted: Mon Sep 22, 2008 7:15 am
by System123
Does it allow you to load files bigger than 64Kb??

Re: PIT and Kernel Problems

Posted: Mon Sep 22, 2008 8:35 am
by Troy Martin
Sadly, no. That loader can load flat binaries, which have a maximum size of 64KB. Anything bigger has to be a different executable format, like Windows PE, ELF, or something else.

It's the sad truth... You'd have to write your own loader to parse the header of the executable and set it up in the right way. Try checking the Wiki.

Troy

Re: PIT and Kernel Problems

Posted: Mon Sep 22, 2008 10:55 am
by System123
Aaaaaah that frustrating. I will see if I can't adapt the other Bootloader I have that loads PE and ELF format into a 2nd Stage loader.

Re: PIT and Kernel Problems

Posted: Mon Sep 22, 2008 4:20 pm
by Troy Martin
Originally the problem with 64KB was the real mode segments (I assume you know about that) but somehow I think it's carried over to pmode. You are in protected mode, right?

Re: PIT and Kernel Problems

Posted: Mon Sep 22, 2008 11:02 pm
by System123
Yes i am in pmode. Is there a way to fix that driver other than creating pe or elf support

Re: PIT and Kernel Problems

Posted: Tue Sep 23, 2008 6:01 pm
by Troy Martin
Not that I know of...

Might want to google it.